home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1995-12-03 | 159.5 KB | 5,631 lines
diff -u -r --new-file last-version/docs/SCO.txt samba-1.9.15p5/docs/SCO.txt --- last-version/docs/SCO.txt Thu Jul 13 21:46:24 1995 +++ samba-1.9.15p5/docs/SCO.txt Fri Dec 1 09:59:21 1995 @@ -1,4 +1,4 @@ -There is an annoying TCPIP bug in SCO Unix. This causes orruption when +There is an annoying TCPIP bug in SCO Unix. This causes corruption when transferring files with Samba. Geza Makay (makayg@math.u-szeged.hu) sends this information: @@ -9,4 +9,8 @@ You do not need anything else but the above patch. It installs in seconds, and corrected the Excel problem. We also had some other minor problems (not only with Samba) that disappeared by installing this patch. + +I've also heard that you need net382e (whatever that is!). This was +reported by Eigil Krogh Sorensen <eks@aar-vki.dk>. + diff -u -r --new-file last-version/docs/Speed.txt samba-1.9.15p5/docs/Speed.txt --- last-version/docs/Speed.txt Wed Nov 22 22:24:44 1995 +++ samba-1.9.15p5/docs/Speed.txt Sun Dec 3 21:46:18 1995 @@ -113,6 +113,19 @@ read-write. For many applications that do their own locking this doesn't matter, but for some it may. + +MEMORY USAGE +------------ + +The biggest user of memory is the MAXDIR option in local.h. This +determines how many open directories are cached in memory. If the +client access lots of large directories and doesn't explicitly close +then when finished then a large MAXDIR can use a lot of server memory. + +The default is 64. In most situations it is safe to reduce it to 16 or +even less. It must be at least 2 to operate correctly. + + LOG LEVEL --------- diff -u -r --new-file last-version/docs/nmbd.8 samba-1.9.15p5/docs/nmbd.8 --- last-version/docs/nmbd.8 Wed Nov 22 22:26:53 1995 +++ samba-1.9.15p5/docs/nmbd.8 Sun Dec 3 18:50:56 1995 @@ -264,7 +264,7 @@ The log files generated are never removed by the server. .RE -.RE +.\" .RE .B -n .I netbios name @@ -324,7 +324,7 @@ mapping of service name (eg., netbios-ns) to service port (eg., 137) and protocol type (eg., udp). See the section "INSTALLATION" below. .RE -.RE +.\" .RE .SH ENVIRONMENT VARIABLES Not applicable. @@ -479,7 +479,8 @@ This man page written by Karl Auer (Karl.Auer@anu.edu.au) See -.B smb.conf(5) for a full list of contributors and details on how to +.B smb.conf(5) +for a full list of contributors and details on how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/nmbd.8.orig samba-1.9.15p5/docs/nmbd.8.orig --- last-version/docs/nmbd.8.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/nmbd.8.orig Wed Nov 22 22:26:53 1995 @@ -0,0 +1,488 @@ +.TH NMBD 8 17/1/1995 nmbd nmbd +.SH NAME +nmbd \- provide netbios nameserver support to clients +.SH SYNOPSIS +.B nmbd +[ +.B -B +.I broadcast address +] [ +.B -I +.I IP address +] [ +.B -D +] [ +.B -C comment string +] [ +.B -G +.I group name +] [ +.B -H +.I netbios hosts file +] [ +.B -N +.I netmask +] [ +.B -d +.I debuglevel +] [ +.B -l +.I log basename +] +.B -n +.I netbios name +] [ +.B -p +.I port number +] + +.SH DESCRIPTION +This program is part of the Samba suite. + +.B nmbd +is a server that understands and can reply to netbios +name service requests, like those produced by LanManager +clients. It also controls browsing. + +LanManager clients, when they start up, may wish to locate a LanManager server. +That is, they wish to know what IP number a specified host is using. + +This program simply listens for such requests, and if its own name is specified +it will respond with the IP number of the host it is running on. "Its own name" +is by default the name of the host it is running on, but this can be overriden +with the +.B -n +option (see "OPTIONS" below). Using the +.B -S +option (see "OPTIONS" below), it can also be instructed to respond with IP +information about other hosts, provided they are locatable via the +gethostbyname() call, or they are in a netbios hosts file. + +Nmbd can also be used as a WINS (Windows Internet Name Server) +server. It will do this automatically by default. What this basically +means is that it will respond to all name requests that it receives +that are not broadcasts, as long as it can resolve the name. +.SH OPTIONS +.B -B + +.RS 3 +On some systems, the server is unable to determine the broadcast address to +use for name registration requests. If your system has this difficulty, this +parameter may be used to specify an appropriate broadcast address. The +address should be given in standard "a.b.c.d" notation. + +Only use this parameter if you are sure that the server cannot properly +determine the proper broadcast address. + +The default broadcast address is determined by the server at run time. If it +encounters difficulty doing so, it makes a guess based on the local IP +number. +.RE +.B -I + +.RS 3 +On some systems, the server is unable to determine the correct IP +address to use. This allows you to override the default choice. +.RE + +.B -D + +.RS 3 +If specified, this parameter causes the server to operate as a daemon. That is, +it detaches itself and runs in the background, fielding requests on the +appropriate port. + +By default, the server will NOT operate as a daemon. +.RE + +.B -C comment string + +.RS 3 +This allows you to set the "comment string" that is shown next to the +machine name in browse listings. + +A %v will be replaced with the Samba version number. + +A %h will be replaced with the hostname. + +It defaults to "Samba %v". +.RE + +.B -G + +.RS 3 +This option allows you to specify a netbios group (also known as +lanmanager domain) that the server should be part of. You may include +several of these on the command line if you like. Alternatively you +can use the -H option to load a netbios hosts file containing domain names. + +At startup, unless the -R switch has been used, the server will +attempt to register all group names in the hosts file and on the +command line (from the -G option). + +The server will also respond to queries on this name. +.RE + +.B -H + +.RS 3 +It may be useful in some situations to be able to specify a list of +netbios names for which the server should send a reply if +queried. This option allows that. The syntax is similar to the +standard /etc/hosts file format, but has some extensions. + +The file contains three columns. Lines beginning with a # are ignored +as comments. The first column is an IP address, or a hostname. If it +is a hostname then it is interpreted as the IP address returned by +gethostbyname() when read. Any IP address of 0.0.0.0 will be +interpreted as the servers own IP address. + +The second column is a netbios name. This is the name that the server +will respond to. It must be less than 20 characters long. + +The third column is optional, and is intended for flags. Currently the +only flags supported are G, S and M. A G indicates that the name is a +group (also known as domain) name. + +At startup all groups known to the server (either from this file or +from the -G option) are registered on the network (unless the -R +option has been selected). + +A S or G means that the specified address is a broadcast address of a +network that you want people to be able to browse you from. Nmbd will +search for a master browser in that domain and will send host +announcements to that machine, informing it that the specifed somain +is available. + +A M means that this name is the default netbios name for this +machine. This has the same affect as specifying the -n option to nmbd. + +After startup the server waits for queries, and will answer queries to +any name known to it. This includes all names in the netbios hosts +file (if any), it's own name, and any names given with the -G option. + +The primary intention of the -H option is to allow a mapping from +netbios names to internet domain names, and to allow the specification +of groups that the server should be part of. + +.B Example: + + # This is a sample netbios hosts file + + # DO NOT USE THIS FILE AS-IS + # YOU MAY INCONVENIENCE THE OWNERS OF THESE IPs + # if you want to include a name with a space in it then + # use double quotes. + + # first put ourselves in the group LANGROUP + 0.0.0.0 LANGROUP G + + # next add a netbios alias for a faraway host + arvidsjaur.anu.edu.au ARVIDSJAUR + + # finally put in an IP for a hard to find host + 130.45.3.213 FREDDY + + # now we want another subnet to be able to browse + # us in the workgroup UNIXSERV + 192.0.2.255 UNIXSERV G + +.RE + +.B -M +.I workgroup name + +.RS 3 +If this parameter is given, the server will look for a master browser +for the specified workgroup name, report success or failure, then +exit. If successful, the IP address of the name located will be +reported. + +If you use the workgroup name "-" then nmbd will search for a master +browser for any workgroup by using the name __MSBROWSE__. + +This option is meant to be used interactively on the command line, not +as a daemon or in inetd. + +.RE +.B -N + +.RS 3 +On some systems, the server is unable to determine the netmask. If +your system has this difficulty, this parameter may be used to specify +an appropriate netmask. The mask should be given in standard +"a.b.c.d" notation. + +Only use this parameter if you are sure that the server cannot properly +determine the proper netmask. + +The default netmask is determined by the server at run time. If it +encounters difficulty doing so, it makes a guess based on the local IP +number. +.RE + +.B -d +.I debuglevel +.RS 3 + +debuglevel is an integer from 0 to 5. + +The default value if this parameter is not specified is zero. + +The higher this value, the more detail will be logged to the log files about +the activities of the server. At level 0, only critical errors and serious +warnings will be logged. Level 1 is a reasonable level for day to day running +- it generates a small amount of information about operations carried out. + +Levels above 1 will generate considerable amounts of log data, and should +only be used when investigating a problem. Levels above 3 are designed for +use only by developers and generate HUGE amounts of log data, most of which +is extremely cryptic. +.RE + +.B -l +.I log file + +.RS 3 +If specified, +.I logfile +specifies a base filename into which operational data from the running server +will be logged. + +The default base name is specified at compile time. + +The base name is used to generate actual log file names. For example, if the +name specified was "log", the following files would be used for log data: + +.RS 3 +log.nmb (containing debugging information) + +log.nmb.in (containing inbound transaction data) + +log.nmb.out (containing outbound transaction data) +.RE + +The log files generated are never removed by the server. +.RE +.RE + +.B -n +.I netbios name + +.RS 3 +This parameter tells the server what netbios name to respond with when +queried. The same name is also registered on startup unless the -R +parameter was specified. + +The default netbios name used if this parameter is not specified is the +name of the host on which the server is running. +.RE + +.B -p +.I port number +.RS 3 + +port number is a positive integer value. + +The default value if this parameter is not specified is 137. + +This number is the port number that will be used when making connections to +the server from client software. The standard (well-known) port number for the +server is 137, hence the default. If you wish to run the server as an ordinary +user rather than as root, most systems will require you to use a port number +greater than 1024 - ask your system administrator for help if you are in this +situation. + +Note that the name server uses UDP, not TCP! + +This parameter is not normally specified except in the above situation. +.RE +.SH FILES + +.B /etc/inetd.conf + +.RS 3 +If the server is to be run by the inetd meta-daemon, this file must contain +suitable startup information for the meta-daemon. See the section +"INSTALLATION" below. +.RE + +.B /etc/rc.d/rc.inet2 + +.RS 3 +(or whatever initialisation script your system uses) + +If running the server as a daemon at startup, this file will need to contain +an appropriate startup sequence for the server. See the section "Installation" +below. +.RE + +.B /etc/services + +.RS 3 +If running the server via the meta-daemon inetd, this file must contain a +mapping of service name (eg., netbios-ns) to service port (eg., 137) and +protocol type (eg., udp). See the section "INSTALLATION" below. +.RE +.RE + +.SH ENVIRONMENT VARIABLES +Not applicable. + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the server software be installed under the /usr/local +hierarchy, in a directory readable by all, writeable only by root. The server +program itself should be executable by all, as users may wish to run the +server themselves (in which case it will of course run with their privileges). +The server should NOT be setuid or setgid! + +The server log files should be put in a directory readable and writable only +by root, as the log files may contain sensitive information. + +The remaining notes will assume the following: + +.RS 3 +nmbd (the server program) installed in /usr/local/smb + +log files stored in /var/adm/smblogs +.RE + +The server may be run either as a daemon by users or at startup, or it may +be run from a meta-daemon such as inetd upon request. If run as a daemon, the +server will always be ready, so starting sessions will be faster. If run from +a meta-daemon some memory will be saved and utilities such as the tcpd +TCP-wrapper may be used for extra security. + +When you've decided, continue with either "Running the server as a daemon" or +"Running the server on request". +.SH RUNNING THE SERVER AS A DAEMON +To run the server as a daemon from the command line, simply put the "-D" option +on the command line. There is no need to place an ampersand at the end of the +command line - the "-D" option causes the server to detach itself from the +tty anyway. + +Any user can run the server as a daemon (execute permissions permitting, of +course). This is useful for testing purposes. + +To ensure that the server is run as a daemon whenever the machine is started, +you will need to modify the system startup files. Wherever appropriate (for +example, in /etc/rc.d/rc.inet2), insert the following line, substituting +values appropriate to your system: + +.RS 3 +/usr/local/smb/nmbd -D -l/var/adm/smblogs/log +.RE + +(The above should appear in your initialisation script as a single line. +Depending on your terminal characteristics, it may not appear that way in +this man page. If the above appears as more than one line, please treat any +newlines or indentation as a single space or TAB character.) + +If the options used at compile time are appropriate for your system, all +parameters except the desired debug level and "-D" may be omitted. See the +section on "Options" above. +.SH RUNNING THE SERVER ON REQUEST +If your system uses a meta-daemon such as inetd, you can arrange to have the +SMB name server started whenever a process attempts to connect to it. This +requires several changes to the startup files on the host machine. If you are +experimenting as an ordinary user rather than as root, you will need the +assistance of your system administrator to modify the system files. + +First, ensure that a port is configured in the file /etc/services. The +well-known port 137 should be used if possible, though any port may be used. + +Ensure that a line similar to the following is in /etc/services: + +.RS 3 +netbios-ns 137/udp +.RE + +Note for NIS/YP users: You may need to rebuild the NIS service maps rather +than alter your local /etc/services file. + +Next, put a suitable line in the file /etc/inetd.conf (in the unlikely event +that you are using a meta-daemon other than inetd, you are on your own). Note +that the first item in this line matches the service name in /etc/services. +Substitute appropriate values for your system in this line (see +.B inetd(8)): + +.RS 3 +netbios-ns dgram udp wait root /usr/local/smb/nmbd -l/var/adm/smblogs/log +.RE + +(The above should appear in /etc/inetd.conf as a single line. Depending on +your terminal characteristics, it may not appear that way in this man page. +If the above appears as more than one line, please treat any newlines or +indentation as a single space or TAB character.) + +Note that there is no need to specify a port number here, even if you are +using a non-standard port number. +.SH TESTING THE INSTALLATION +If running the server as a daemon, execute it before proceeding. If +using a meta-daemon, either restart the system or kill and restart the +meta-daemon. Some versions of inetd will reread their configuration tables if +they receive a HUP signal. + +To test whether the name server is running, start up a client +.I on a different machine +and see whether the desired name is now present. Alternatively, run +the nameserver +.I on a different machine +specifying "-L netbiosname", where "netbiosname" is the name you have +configured the test server to respond with. The command should respond +with success, and the IP number of the machine using the specified netbios +name. You may need the -B parameter on some systems. See the README +file for more information on testing nmbd. + +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the server has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B inetd(8), +.B smbd(8), +.B smb.conf(5), +.B smbclient(1), +.B testparm(1), +.B testprns(1) + +.SH DIAGNOSTICS +[This section under construction] + +Most diagnostics issued by the server are logged in the specified log file. The +log file name is specified at compile time, but may be overridden on the +command line. + +The number and nature of diagnostics available depends on the debug level used +by the server. If you have problems, set the debug level to 3 and peruse the +log files. + +Most messages are reasonably self-explanatory. Unfortunately, at time of +creation of this man page the source code is still too fluid to warrant +describing each and every diagnostic. At this stage your best bet is still +to grep the source code and inspect the conditions that gave rise to the +diagnostics you are seeing. + +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +This man page written by Karl Auer (Karl.Auer@anu.edu.au) + +See +.B smb.conf(5) for a full list of contributors and details on how to +submit bug reports, comments etc. + + + + + diff -u -r --new-file last-version/docs/smb.conf.5 samba-1.9.15p5/docs/smb.conf.5 --- last-version/docs/smb.conf.5 Thu Nov 23 11:03:28 1995 +++ samba-1.9.15p5/docs/smb.conf.5 Sun Dec 3 19:12:21 1995 @@ -320,6 +320,10 @@ auto services +browse list + +character set + config file deadtime @@ -698,9 +702,30 @@ .B Example: browseable = No +.SS browse list (G) + +This boolean determines if the server will allow the client to query +the local browse list, which holds the list of available servers in +the workgroup. + +It defaults to yes. + .SS case sig names (G) See "case sensitive" +.SS character set (G) + +This option allows you to select an alternate character set for the +server, to allow for correct translation of "foreign" characters. + +Currently the only supported alternate character set is "iso8859-1" +which is probably good for sweden and maybe other nordic countries. + +The default is to use the PCs characters untranslated. + +.B Example: + character set = iso8859-1 + .SS comment (S) This is a text field that is seen when a client does a net view to list what shares are available. It will also be used when browsing is @@ -1613,7 +1638,8 @@ .B password level is set to 1 (one), the following combinations would be tried if "FRED" failed: "Fred", "fred", "fRed", "frEd", "freD". If -.B password level was set to 2 (two), the following combinations would also be +.B password level +was set to 2 (two), the following combinations would also be tried: "FRed", "FrEd", "FreD", "fREd", "fReD", "frED". And so on. The higher value this parameter is set to the more likely it is that a mixed diff -u -r --new-file last-version/docs/smb.conf.5.orig samba-1.9.15p5/docs/smb.conf.5.orig --- last-version/docs/smb.conf.5.orig Wed Nov 22 22:47:24 1995 +++ samba-1.9.15p5/docs/smb.conf.5.orig Sun Dec 3 00:19:58 1995 @@ -320,6 +320,8 @@ auto services +browse list + config file deadtime @@ -414,6 +416,10 @@ strip dot +syslog + +syslog only + time offset username map @@ -694,6 +700,14 @@ .B Example: browseable = No +.SS browse list (G) + +This boolean determines if the server will allow the client to query +the local browse list, which holds the list of available servers in +the workgroup. + +It defaults to yes. + .SS case sig names (G) See "case sensitive" @@ -2293,6 +2307,43 @@ .B Example: sync always = yes + +.SS syslog (G) + +This integer parameter is used in conjunction with +.B debug level +to filter out debugging messages destined for the system logger. +Only those debugging messages that are +.I less than or equal to +.B debug level +and +.I less than +.B syslog +are sent to the system logger. Thus, a value of 0 can be used +to turn off system logging. + +You must compile with -DSYSLOG in order for system logging to +be enabled. + +.B Default: + syslog = 1 + +.B Example: + syslog = 0 + +.SS syslog only (G) + +This boolean controls whether debugging messages are sent to the +log file and system logger, or only to the system logger. + +You must compile with -DSYSLOG in order for system logging to +be enabled. + +.B Default: + syslog only = False + +.B Example: + syslog only = True .SS time offset (G) This parameter is a setting in minutes to add to the normal GMT to diff -u -r --new-file last-version/docs/smbclient.1 samba-1.9.15p5/docs/smbclient.1 --- last-version/docs/smbclient.1 Wed Nov 22 22:28:03 1995 +++ samba-1.9.15p5/docs/smbclient.1 Sun Dec 3 18:50:56 1995 @@ -50,7 +50,8 @@ an interface similar to that of the .B ftp program (see -.B ftp(1)). Operations include things like getting files from the +.B ftp(1)). +Operations include things like getting files from the server to the local machine, putting files from the local machine to the server, retrieving directory information from the server and so on. @@ -316,7 +317,7 @@ The log files generated are never removed by the client. .RE -.RE +.\" .RE .B -n .I netbios name @@ -850,7 +851,7 @@ files that match the mask specified using the .B mask command will be retrieved. See also the -.mask +.B mask command. When recursion is toggled OFF, only files from the current working @@ -936,7 +937,8 @@ To test the client, you will need to know the name of a running Lan manager server. It is possible to run the smbd (see -.B smbd(8)) as an ordinary user - running that server as a daemon on a +.B smbd(8)) +as an ordinary user - running that server as a daemon on a user-accessible port (typically any port number over 1024) would provide a suitable test server. .SH VERSION @@ -976,5 +978,6 @@ This man page written by Karl Auer (Karl.Auer@anu.edu.au) See -.B smb.conf(5) for a full list of contributors and details on how to +.B smb.conf(5) +for a full list of contributors and details on how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbclient.1.orig samba-1.9.15p5/docs/smbclient.1.orig --- last-version/docs/smbclient.1.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/smbclient.1.orig Wed Nov 22 22:28:03 1995 @@ -0,0 +1,980 @@ +.TH SMBCLIENT 1 17/1/1995 smbclient smbclient +.SH NAME +smbclient \- ftp-like Lan Manager client program +.SH SYNOPSIS +.B smbclient +.B servicename +[ +.B password +] [ +.B -A +] [ +.B -E +] [ +.B -L +.I host +] [ +.B -M +.I host +] [ +.B -I +.I IP number +] [ +.B -N +] [ +.B -P +] [ +.B -U +.I username +] [ +.B -d +.I debuglevel +] [ +.B -l +.I log basename +] [ +.B -n +.I netbios name +] [ +.B -O +.I socket options +] [ +.B -p +.I port number +] +.SH DESCRIPTION +This program is part of the Samba suite. + +.B smbclient +is a client that can 'talk' to a Lan Manager server. It offers +an interface similar to that of the +.B ftp +program (see +.B ftp(1)). Operations include things like getting files from the +server to the local machine, putting files from the local machine to +the server, retrieving directory information from the server and so on. + +NOTE: Ricky Poulten (poultenr@logica.co.uk) has written a "tar" +extension to smbclient that allows you to back up and restore your +lan-manager compatible network using smbclient. + +You can fetch the tar extension from the "contributed" section on +nimbus. ftp://nimbus.anu.edu.au/pub/tridge/samba/contributed/ + + +.SH OPTIONS +.B servicename +.RS 3 +.B servicename +is the name of the service you want to use on the server. A service +name takes the form +.B "\\\\\\\\server\\\\service" +where +.B server +is the netbios name of the Lan Manager server offering the desired service and +.B service +is the name of the service offered. Thus to connect to the service "printer" +on the Lan Manager server "lanman", you would use the servicename + +.RS 10 +.B "\\\\\\\\lanman\\\\printer" +.RE + +Note that the server name required is NOT necessarily the host name of the +server! The name required is a Lan Manager server name, which may or may not +be the same as the hostname of the machine running the server. +.RE + +.B password +.RS 3 +.B +password +is the password required to access the specified service on the +specified server. If supplied, the +.B -N +option (suppress password prompt) is assumed. + +There is no default password. If no password is supplied on the command line +(either here or using the +.B -U +option (see below)) and +.B -N +is not specified, the client will prompt for a password, even if the desired +service does not require one. (If prompted for a password and none is +required, simply press ENTER to provide a null password.) + +Note: Some servers (including OS/2 and Windows for Workgroups) insist +on an uppercase password. Lowercase or mixed case passwords may be +rejected by these servers. + +Be cautious about including passwords in scripts. +.RE + +.B -A + +.RS 3 +This parameter, if specified, causes the maximum debug level to be selected. +Be warned that this generates prodigious amounts of debug data. There is also +a security issue involved, as at the maximum debug level cleartext passwords +may be written to some log files. +.RE + +.B -L + +.RS 3 +This option allows you to look at what services are available on a +server. You use it as "smbclient -L host" and a list should appear. +The -I option may be useful if your netbios names don't match your +tcp/ip host names or if you are trying to reach a host on another +network. For example: + +smbclient -L ftp -I ftp.microsoft.com + +will list the shares available on microsofts public server. +.RE + +.B -M + +.RS 3 +This options allows you to send messages, using the "WinPopup" +protocol, to another computer. Once a connection is established you +then type your message, pressing ^D (control-D) to end. + +If the receiving computer is running WinPopup the user will receive +the message and probably a beep. If they are not running WinPopup the +message will be lost, and no error message will occur. + +The message is also automatically truncated if the message is over +1600 bytes, as this is the limit of the protocol. + +One useful trick is to cat the message through smbclient. For example: + +cat mymessage.txt | smbclient -M FRED + +will send the message in the file "mymessage.txt" to the machine FRED. + +You may also find the -U and -I options useful, as they allow you to +control the FROM and TO parts of the message. + +Samba currently has no way of receiving WinPopup messages. + +Note: Copy WinPopup into the startup group on your WfWg PCs if you +want them to always be able to receive messages. +.RE + +.B -E + +.RS 3 +This parameter, if specified, causes the client to write messages to the +standard error stream (stderr) rather than to the standard output stream. + +By default, the client writes messages to standard output - typically the +user's tty. +.RE + +.B -I +.I IP number + +.RS 3 +.I IP number +represents the IP number of the server to connect to. It should +be specified in standard "a.b.c.d" notation. + +Normally the client will attempt to locate the specified Lan Manager server +by looking it up - that is, broadcasting a request for the given server to +identify itself. Using this parameter will force the client to assume that +the server is on the machine with the specified IP number. + +There is no default for this parameter. If not supplied, it will be determined +automatically by the client as described above. +.RE + +.B -N + +.RS 3 +If specified, this parameter suppresses the normal password prompt from the +client to the user. This is useful when accessing a service that does not +require a password. + +Unless a password is specified on the command line or this parameter is +specified, the client will request a password. +.RE + +.B -O +.I socket options +.RS 3 + +See the socket options section of smb.conf(5) for details + +.RE +.B -P + +.RS 3 +If specified, the service requested will be connected to as a printer service +rather than as a normal filespace service. Operations such as put and get +will not be applicable for such a connection. + +By default, services will be connected to as NON-printer services. +.RE + +.B -U +.I username + +.RS 3 +.I username +is the user name that will be used by the client to make a connection, +assuming your server is running a protocol that allows for usernames. + +Some servers are fussy about the case of this name, and some insist +that it must be a valid netbios name. + +If no +.I username +is supplied, it will default to an uppercase version of the +environment variable +.B USER +or +.B LOGNAME +in that order. +If no +.I username +is supplied and neither environment variable exists the user name will +be empty. + +If the service you are connecting to requires a password, it can be supplied +using the +.B -U +option, by appending a percent symbol ("%") then the password to +.I username. +For example, to attach to a service as user "fred" with password "secret", you +would specify +.B -U +.I fred%secret +on the command line. Note that there are no spaces around the percent symbol. + +If you specify the password as part of +.I username +then the +.B -N +option (suppress password prompt) is assumed. + +If you specify the password as a parameter AND as part of +.I username +then the password as part of +.I username +will take precedence. Putting nothing before or nothing after the percent +symbol will cause an empty username or an empty password to be used, +respectively. + +Note: Some servers (including OS/2 and Windows for Workgroups) insist +on an uppercase password. Lowercase or mixed case passwords may be +rejected by these servers. + +Be cautious about including passwords in scripts. +.RE + +.B -d +.I debuglevel +.RS 3 + +debuglevel is an integer from 0 to 5. + +The default value if this parameter is not specified is zero. + +The higher this value, the more detail will be logged to the log files about +the activities of the client. At level 0, only critical errors and serious +warnings will be logged. Level 1 is a reasonable level for day to day running +- it generates a small amount of information about operations carried out. + +Levels above 1 will generate considerable amounts of log data, and should +only be used when investigating a problem. Levels above 3 are designed for +use only by developers and generate HUGE amounts of log data, most of which +is extremely cryptic. +.RE + +.B -l +.I log basename + +.RS 3 +If specified, +.I log basename +specifies a base filename into which operational data from the running client +will be logged. + +The default base name is specified at compile time. + +The base name is used to generate actual log file names. For example, if the +name specified was "log", the following files would be used for log data: + +.RS 3 +log.client.debug (containing debugging information) + +log.client.in (containing inbound transaction data) + +log.client.out (containing outbound transaction data) +.RE + +The log files generated are never removed by the client. +.RE +.RE + +.B -n +.I netbios name + +.RS 3 +By default, the client will use the local machine's hostname (in +uppercase) as its netbios name. This parameter allows you to override +the host name and use whatever netbios name you wish. +.RE + +.B -p +.I port number +.RS 3 + +port number is a positive integer value. + +The default value if this parameter is not specified is 139. + +This number is the port number that will be used when making connections to +the server. The standard (well-known) port number for the server is 139, +hence the default. + +This parameter is not normally specified. +.RE + +.SH OPERATIONS +Once the client is running, the user is presented with a prompt, "smb: \\>". +The backslash ("\\") indicates the current working directory on the server, +and will change if the current working directory is changed. + +The prompt indicates that the client is ready and waiting to carry out a user +command. Each command is a single word, optionally followed by parameters +specific to that command. Command and parameters are space-delimited unless +these notes specifically state otherwise. All commands are case-insensitive. +Parameters to commands may or may not be case sensitive, depending on the +command. + +You can specify file names which have spaces in them by quoting the +name with double quotes, for example "a long file name". + +Parameters shown in square brackets (eg., "[parameter]") are optional. If not +given, the command will use suitable defaults. Parameters shown in angle +brackets (eg., "<parameter>") are required. + +Note that all commands operating on the server are actually performed by +issuing a request to the server. Thus the behaviour may vary from server to +server, depending on how the server was implemented. + +The commands available are given here in alphabetical order. + +.B ? +.RS 3 +.B Parameters: +.RS 3 +.I [command] + +.RE +.B Description: +.RS 3 +If +.I command +is specified, the +.B ? +command will display a brief informative message about the specified command. + +If no command is specified, a list of available commands will be displayed. +.RE +.RE + +.B ! +.RS 3 +.B Parameters: +.RS 3 +.I [shell command] + +.RE +.B Description: +.RS 3 +If +.I shell command +is specified, the +.B ! +command will execute a shell locally and run the specified shell command. If +no command is specified, a shell will be run. +.RE +.RE + +.B cd +.RS 3 +.B Parameters: +.RS 3 +.I [directory name] + +.RE +.B Description: +.RS 3 +If +.I directory name +is specified, the current working directory +.B on the server +will be changed to the directory specified. This operation will fail if for +any reason the specified directory is inaccessible. + +If no directory name is specified, the current working directory +.B on the server +will be reported. +.RE +.RE + +.B del +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +The client will request that the server attempt to delete all files matching +.I mask +from the current working directory +.B on the server. +.RE +.RE + +.B dir +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +A list of the files matching +.I mask +in the current working directory +.B on the server +will be retrieved from the server and displayed. +.RE +.RE + +.B exit +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +Terminate the connection with the server and exit from the program. +.RE +.RE + +.B get +.RS 3 +.B Parameters: +.RS 3 +.I <remote file name> [local file name] + +.RE +.B Description: +.RS 3 +Copy the file called +.I remote file name +from the server to the machine running the client. If specified, name the +local copy +.I local file name. +Note that all transfers in smbclient are binary. See also the +.B lowercase +command. +.RE +.RE + +.B help +.RS 3 +.B Parameters: +.RS 3 +.I [command] + +.RE +.B Description: +.RS 3 +See the +.B ? +command above. +.RE +.RE + +.B lcd +.RS 3 +.B Parameters: +.RS 3 +.I [directory name] + +.RE +.B Description: +.RS 3 +If +.I directory name +is specified, the current working directory +.B on the local machine +will be changed to the directory specified. This operation will fail if for +any reason the specified directory is inaccessible. + +If no directory name is specified, the name of the current working directory +.B on the local machine +will be reported. +.RE +.RE + +.B lowercase +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +Toggle lowercasing of filenames for the +.B get +and +.B mget +commands. + +When lowercasing is toggled ON, local filenames are converted to lowercase +when using the +.B get +and +.B mget +commands. This is often useful when copying (say) MSDOS files from a server, +because lowercase filenames are the norm on Unix systems. +.RE +.RE + +.B ls +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +See the +.B dir +command above. +.RE +.RE + +.B mask +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +This command allows the user to set up a mask which will be used during +recursive operation of the +.B mget +and +.B mput +commands. + +The masks specified to the +.B mget +and +.B mput +commands act as filters for directories +rather than files when recursion is toggled ON. + +The mask specified with the +.B mask +command is necessary to filter files within those directories. For example, +if the mask specified in an +.B mget +command is "source*" +.I and +the mask specified with the +.B mask +command is "*.c" +.I and +recursion is toggled ON, the +.B mget +command will retrieve all files matching "*.c" in all directories below +and including all directories matching "source*" in the current working +directory. + +Note that the value for +.I mask +defaults to blank (equivalent to "*") and remains so until the +.B mask +command is used to change it. It retains the most recently specified value +indefinitely. To avoid unexpected results it would be wise to change the +value of +.I mask +back to "*" after using the +.B mget +or +.B mput +commands. +.RE +.RE + +.B md +.RS 3 +.B Parameters: +.RS 3 +.I <directory name> + +.RE +.B Description: +.RS 3 +See the +.B mkdir +command. +.RE +.RE + +.B mget +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +Copy all files matching +.I mask +from the server to the machine running the client. + +Note that +.I mask +is interpreted differently during recursive operation and non-recursive +operation - refer to the +.B recurse +and +.B mask +commands for more information. Note that all transfers in smbclient are +binary. See also the +.B lowercase +command. +.RE +.RE + +.B mkdir +.RS 3 +.B Parameters: +.RS 3 +.I <directory name> + +.RE +.B Description: +.RS 3 +Create a new directory +.B on the server +(user access privileges permitting) with the specified name. +.RE +.RE + +.B mput +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +Copy all files matching +.I mask +in the current working directory +.B on the local machine +to the current working directory on the server. + +Note that +.I mask +is interpreted differently during recursive operation and non-recursive +operation - refer to the +.B recurse +and +.B mask +commands for more information. Note that all transfers in smbclient are +binary. +.RE +.RE + +.B print +.RS 3 +.B Parameters: +.RS 3 +.I <file name> + +.RE +.B Description: +.RS 3 +Print the specified file +.B from the local machine +through a printable service on the server. + +See also the +.B printmode +command. +.RE +.RE + +.B printmode +.RS 3 +.B Parameters: +.RS 3 +.I <graphics or text> + +.RE +.B Description: +.RS 3 +Set the print mode to suit either binary data (such as graphical information) +or text. Subsequent +.B print +commands will use the currently set print mode. +.RE +.RE + +.B prompt +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +Toggle prompting for filenames during operation of the +.B mget +and +.B mput +commands. + +When toggled ON, the user will be prompted to confirm the transfer of each +file during these commands. When toggled OFF, all specified files will be +transferred without prompting. +.RE +.RE + +.B put +.RS 3 +.B Parameters: +.RS 3 +.I <local file name> [remote file name] + +.RE +.B Description: +.RS 3 +Copy the file called +.I local file name +from the machine running the client to the server. If specified, name the +remote copy +.I remote file name. +Note that all transfers in smbclient are binary. See also the +.B lowercase +command. +.RE +.RE + +.B queue +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +Displays the print queue, showing the job id, name, size and current status. +.RE +.RE + +.B quit +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +See the +.B exit +command. +.RE +.RE + +.B rd +.RS 3 +.B Parameters: +.RS 3 +.I <directory name> + +.RE +.B Description: +.RS 3 +See the +.B rmdir +command. +.RE +.RE + +.B recurse +.RS 3 +.B Parameters: +.RS 3 +None. + +.RE +.B Description: +.RS 3 +Toggle directory recursion for the commands +.B mget +and +.B mput +. + +When toggled ON, these commands will process all directories in the source +directory (ie., the directory they are copying +.I from +) and will recurse into any that match the mask specified to the command. Only +files that match the mask specified using the +.B mask +command will be retrieved. See also the +.mask +command. + +When recursion is toggled OFF, only files from the current working +directory on the source machine that match the mask specified to the +.B mget +or +.B mput +commands will be copied, and any mask specified using the +.B mask +command will be ignored. +.RE +.RE + +.B rm +.RS 3 +.B Parameters: +.RS 3 +.I <mask> + +.RE +.B Description: +.RS 3 +Remove all files matching +.I mask +from the current working directory +.B on the server. +.RE +.RE + +.B rmdir +.RS 3 +.B Parameters: +.RS 3 +.I <directory name> + +.RE +.B Description: +.RS 3 +Remove the specified directory (user access privileges permitting) +.B from the server. +.RE +.RE + + +.SH NOTES +Some servers are fussy about the case of supplied usernames, passwords, share +names (aka service names) and machine names. If you fail to connect try +giving all parameters in uppercase. + +It is often necessary to use the +.B -n +option when connecting to some types +of servers. For example OS/2 LanManager insists on a valid netbios name +being used, so you need to supply a valid name that would be known to +the server. + +.B smbclient +supports long file names where the server supports the LANMAN2 +protocol. + +.SH FILES +Not applicable. + +.SH ENVIRONMENT VARIABLES +.B USER +.RS 3 +The variable USER may contain the username of the person using the client. +This information is used only if the protocol level is high enough to support +session-level passwords. +.RE + +.SH INSTALLATION +The location of the client program is a matter for individual system +administrators. The following are thus suggestions only. + +It is recommended that the client software be installed under the /usr/local +hierarchy, in a directory readable by all, writeable only by root. The client +program itself should be executable by all. The client should NOT be setuid +or setgid! + +The client log files should be put in a directory readable and writable only +by the user. + +To test the client, you will need to know the name of a running Lan manager +server. It is possible to run the smbd (see +.B smbd(8)) as an ordinary user - running that server as a daemon on a +user-accessible port (typically any port number over 1024) would +provide a suitable test server. +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the client software, so it is possible that your version of +the client has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B smbd(8) + +.SH DIAGNOSTICS +[This section under construction] + +Most diagnostics issued by the client are logged in a specified log file. The +log file name is specified at compile time, but may be overridden on the +command line. + +The number and nature of diagnostics available depends on the debug level used +by the client. If you have problems, set the debug level to 3 and peruse the +log files. + +Most messages are reasonably self-explanatory. Unfortunately, at time of +creation of this man page the source code is still too fluid to warrant +describing each and every diagnostic. At this stage your best bet is still +to grep the source code and inspect the conditions that gave rise to the +diagnostics you are seeing. + +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +This man page written by Karl Auer (Karl.Auer@anu.edu.au) + +See +.B smb.conf(5) for a full list of contributors and details on how to +submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbd.8 samba-1.9.15p5/docs/smbd.8 --- last-version/docs/smbd.8 Wed Nov 22 22:28:10 1995 +++ samba-1.9.15p5/docs/smbd.8 Sun Dec 3 18:50:56 1995 @@ -35,12 +35,14 @@ An extensive description of the services that the server can provide is given in the man page for the configuration file controlling the attributes of those services (see -.B smb.conf(5)). This man page will not describe the services, but +.B smb.conf(5)). +This man page will not describe the services, but will concentrate on the administrative aspects of running the server. Please note that there are significant security implications to running this server, and -.B smb.conf(5) should be regarded as mandatory reading before proceeding with +.B smb.conf(5) +should be regarded as mandatory reading before proceeding with installation. A session is created whenever a client requests one. Each client gets a copy @@ -186,7 +188,7 @@ clients. See .B smb.conf(5) for more information. .RE -.RE +.\" .RE .SH LIMITATIONS @@ -403,5 +405,6 @@ This man page written by Karl Auer (Karl.Auer@anu.edu.au) See -.B smb.conf(5) for a full list of contributors and details on how to +.B smb.conf(5) +for a full list of contributors and details on how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbd.8.orig samba-1.9.15p5/docs/smbd.8.orig --- last-version/docs/smbd.8.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/smbd.8.orig Wed Nov 22 22:28:10 1995 @@ -0,0 +1,407 @@ +.TH SMBD 8 17/1/1995 smbd smbd +.SH NAME +smbd \- provide SMB (aka LanManager) services to clients +.SH SYNOPSIS +.B smbd +[ +.B -D +] [ +.B -a +] [ +.B -d +.I debuglevel +] [ +.B -l +.I log file +] [ +.B -p +.I port number +] [ +.B -O +.I socket options +] [ +.B -s +.I configuration file +] +.SH DESCRIPTION +This program is part of the Samba suite. + +.B smbd +is a server that can provide most SMB services. The +server provides filespace and printer services to clients using the SMB +protocol. This is compatible with the LanManager protocol, and can +service LanManager clients. + +An extensive description of the services that the server can provide is given +in the man page for the configuration file controlling the attributes of those +services (see +.B smb.conf(5)). This man page will not describe the services, but +will concentrate on the administrative aspects of running the server. + +Please note that there are significant security implications to running this +server, and +.B smb.conf(5) should be regarded as mandatory reading before proceeding with +installation. + +A session is created whenever a client requests one. Each client gets a copy +of the server for each session. This copy then services all connections made +by the client during that session. When all connections from its client are +are closed, the copy of the server for that client terminates. + +The configuration file is automatically reloaded if it changes. You +can force a reload by sending a SIGHUP to the server. + +.SH OPTIONS +.B -D + +.RS 3 +If specified, this parameter causes the server to operate as a daemon. That is, +it detaches itself and runs in the background, fielding requests on the +appropriate port. + +By default, the server will NOT operate as a daemon. +.RE + +.B -a + +.RS 3 +If this parameter is specified, the log files will be overwritten with each +new connection. By default, the log files will be appended to. +.RE + +.B -d +.I debuglevel +.RS 3 + +debuglevel is an integer from 0 to 5. + +The default value if this parameter is not specified is zero. + +The higher this value, the more detail will be logged to the log files about +the activities of the server. At level 0, only critical errors and serious +warnings will be logged. Level 1 is a reasonable level for day to day running +- it generates a small amount of information about operations carried out. + +Levels above 1 will generate considerable amounts of log data, and should +only be used when investigating a problem. Levels above 3 are designed for +use only by developers and generate HUGE amounts of log data, most of which +is extremely cryptic. +.RE + +.B -l +.I log file + +.RS 3 +If specified, +.I logfile +specifies a base filename into which operational data from the running server +will be logged. + +The default base name is specified at compile time. + +The base name is used to generate actual log file names. For example, if the +name specified was "log", the following files would be used for log data: + +.RS 3 +log.debug (containing debugging information) + +log.in (containing inbound transaction data) + +log.out (containing outbound transaction data) +.RE + +The log files generated are never removed by the server. +.RE + +.B -O +.I socket options +.RS 3 + +See the socket options section of smb.conf(5) for details + +.RE +.B -p +.I port number +.RS 3 + +port number is a positive integer value. + +The default value if this parameter is not specified is 139. + +This number is the port number that will be used when making connections to +the server from client software. The standard (well-known) port number for the +server is 139, hence the default. If you wish to run the server as an ordinary +user rather than as root, most systems will require you to use a port number +greater than 1024 - ask your system administrator for help if you are in this +situation. + +This parameter is not normally specified except in the above situation. +.RE + +.B -s +.I configuration file + +.RS 3 +The default configuration file name is determined at compile time. + +The file specified contains the configuration details required by the server. +The information in this file includes server-specific information such as +what printcap file to use, as well as descriptions of all the services that the +server is to provide. See +.B smb.conf(5) for more information. +.RE + +.SH FILES + +.B /etc/inetd.conf + +.RS 3 +If the server is to be run by the inetd meta-daemon, this file must contain +suitable startup information for the meta-daemon. See the section +"INSTALLATION" below. +.RE + +.B /etc/rc + +.RS 3 +(or whatever initialisation script your system uses) + +If running the server as a daemon at startup, this file will need to contain +an appropriate startup sequence for the server. See the section "INSTALLATION" +below. +.RE + +.B /etc/services + +.RS 3 +If running the server via the meta-daemon inetd, this file must contain a +mapping of service name (eg., netbios-ssn) to service port (eg., 139) and +protocol type (eg., tcp). See the section "INSTALLATION" below. +.RE + +.B /usr/local/smb/smb.conf + +.RS 3 +This file describes all the services the server is to make available to +clients. See +.B smb.conf(5) for more information. +.RE +.RE + +.SH LIMITATIONS + +On some systems smbd cannot change uid back to root after a setuid() call. +Such systems are called "trapdoor" uid systems. If you have such a system, +you will be unable to connect from a client (such as a PC) as two different +users at once. Attempts to connect the second user will result in "access +denied" or similar. + +.SH ENVIRONMENT VARIABLES + +.B PRINTER + +.RS 3 +If no printer name is specified to printable services, most systems will +use the value of this variable (or "lp" if this variable is not defined) +as the name of the printer to use. This is not specific to the server, +however. +.RE + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the server software be installed under the +/usr/local hierarchy, in a directory readable by all, writeable only +by root. The server program itself should be executable by all, as +users may wish to run the server themselves (in which case it will of +course run with their privileges). The server should NOT be +setuid. On some systems it may be worthwhile to make smbd setgid to an +empty group. This is because some systems may have a security hole where +daemon processes that become a user can be attached to with a +debugger. Making the smbd file setgid to an empty group may prevent +this hole from being exploited. This secrity hole and the suggested +fix has only been confirmed on Linux at the time this was written. It +is possible that this hole only exists in Linux, as testing on other +systems has thus far shown them to be immune. + +The server log files should be put in a directory readable and writable only +by root, as the log files may contain sensitive information. + +The configuration file should be placed in a directory readable and writable +only by root, as the configuration file controls security for the services +offered by the server. The configuration file can be made readable by all if +desired, but this is not necessary for correct operation of the server and +is not recommended. A sample configuration file "smb.conf.sample" is supplied +with the source to the server - this may be renamed to "smb.conf" and +modified to suit your needs. + +The remaining notes will assume the following: + +.RS 3 +smbd (the server program) installed in /usr/local/smb + +smb.conf (the configuration file) installed in /usr/local/smb + +log files stored in /var/adm/smblogs +.RE + +The server may be run either as a daemon by users or at startup, or it may +be run from a meta-daemon such as inetd upon request. If run as a daemon, the +server will always be ready, so starting sessions will be faster. If run from +a meta-daemon some memory will be saved and utilities such as the tcpd +TCP-wrapper may be used for extra security. + +When you've decided, continue with either "RUNNING THE SERVER AS A DAEMON" or +"RUNNING THE SERVER ON REQUEST". +.SH RUNNING THE SERVER AS A DAEMON +To run the server as a daemon from the command line, simply put the "-D" option +on the command line. There is no need to place an ampersand at the end of the +command line - the "-D" option causes the server to detach itself from the +tty anyway. + +Any user can run the server as a daemon (execute permissions permitting, of +course). This is useful for testing purposes, and may even be useful as a +temporary substitute for something like ftp. When run this way, however, the +server will only have the privileges of the user who ran it. + +To ensure that the server is run as a daemon whenever the machine is started, +and to ensure that it runs as root so that it can serve multiple clients, you +will need to modify the system startup files. Wherever appropriate (for +example, in /etc/rc), insert the following line, substituting +port number, log file location, configuration file location and debug level as +desired: + +.RS 3 +/usr/local/smb/smbd -D -l /var/adm/smblogs/log -s /usr/local/smb/smb.conf +.RE + +(The above should appear in your initialisation script as a single line. +Depending on your terminal characteristics, it may not appear that way in +this man page. If the above appears as more than one line, please treat any +newlines or indentation as a single space or TAB character.) + +If the options used at compile time are appropriate for your system, all +parameters except the desired debug level and "-D" may be omitted. See the +section "OPTIONS" above. +.SH RUNNING THE SERVER ON REQUEST +If your system uses a meta-daemon such as inetd, you can arrange to have the +smbd server started whenever a process attempts to connect to it. This requires +several changes to the startup files on the host machine. If you are +experimenting as an ordinary user rather than as root, you will need the +assistance of your system administrator to modify the system files. + +You will probably want to set up the name server +.B nmbd +at the same time as +the smbd - refer to the man page +.B nmbd(8). + +First, ensure that a port is configured in the file /etc/services. The +well-known port 139 should be used if possible, though any port may be used. + +Ensure that a line similar to the following is in /etc/services: + +.RS 3 +netbios-ssn 139/tcp +.RE + +Note for NIS/YP users - you may need to rebuild the NIS service maps rather +than alter your local /etc/services file. + +Next, put a suitable line in the file /etc/inetd.conf (in the unlikely event +that you are using a meta-daemon other than inetd, you are on your own). Note +that the first item in this line matches the service name in /etc/services. +Substitute appropriate values for your system in this line (see +.B inetd(8)): + +.RS 3 +netbios-ssn stream tcp nowait root /usr/local/smb/smbd -d1 +-l/var/adm/smblogs/log -s/usr/local/smb/smb.conf +.RE + +(The above should appear in /etc/inetd.conf as a single line. Depending on +your terminal characteristics, it may not appear that way in this man page. +If the above appears as more than one line, please treat any newlines or +indentation as a single space or TAB character.) + +Note that there is no need to specify a port number here, even if you are +using a non-standard port number. + +Lastly, edit the configuration file to provide suitable services. To start +with, the following two services should be all you need: + +.RS 3 +[homes] +.RS 3 + writable = yes +.RE + +[printers] +.RS 3 + writable = no + printable = yes + path = /tmp + public = yes +.RE +.RE + +This will allow you to connect to your home directory and print to any printer +supported by the host (user privileges permitting). +.SH TESTING THE INSTALLATION +If running the server as a daemon, execute it before proceeding. If +using a meta-daemon, either restart the system or kill and restart the +meta-daemon. Some versions of inetd will reread their configuration tables if +they receive a HUP signal. + +If your machine's name is "fred" and your name is "mary", you should now be +able to connect to the service "\\\\fred\\mary". + +To properly test and experiment with the server, we recommend using the +smbclient program (see +.B smbclient(1)). +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the server has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B hosts_access(5), +.B inetd(8), +.B nmbd(8), +.B smb.conf(5), +.B smbclient(1), +.B testparm(1), +.B testprns(1) + +.SH DIAGNOSTICS +[This section under construction] + +Most diagnostics issued by the server are logged in a specified log file. The +log file name is specified at compile time, but may be overridden on the +command line. + +The number and nature of diagnostics available depends on the debug level used +by the server. If you have problems, set the debug level to 3 and peruse the +log files. + +Most messages are reasonably self-explanatory. Unfortunately, at time of +creation of this man page the source code is still too fluid to warrant +describing each and every diagnostic. At this stage your best bet is still +to grep the source code and inspect the conditions that gave rise to the +diagnostics you are seeing. + +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +This man page written by Karl Auer (Karl.Auer@anu.edu.au) + +See +.B smb.conf(5) for a full list of contributors and details on how to +submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbrun.1 samba-1.9.15p5/docs/smbrun.1 --- last-version/docs/smbrun.1 Wed Nov 22 22:28:16 1995 +++ samba-1.9.15p5/docs/smbrun.1 Sun Dec 3 18:50:56 1995 @@ -66,5 +66,6 @@ This man page was written by Karl Auer (Karl.Auer@anu.edu.au) See -.B smb.conf(5) for a full list of contributors and details of how to +.B smb.conf(5) +for a full list of contributors and details of how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbrun.1.orig samba-1.9.15p5/docs/smbrun.1.orig --- last-version/docs/smbrun.1.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/smbrun.1.orig Wed Nov 22 22:28:16 1995 @@ -0,0 +1,70 @@ +.TH SMBRUN 1 17/1/1995 smbrun smbrun +.SH NAME +smbrun \- interface program between smbd and external programs +.SH SYNOPSIS +.B smbrun +.I shell-command +.SH DESCRIPTION +This program is part of the Samba suite. + +.B smbrun +is a very small 'glue' program, which runs shell commands for +the +.B smbd +daemon (see +.B smbd(8)). + +It first changes to the highest effective user and group ID that it can, +then runs the command line provided using the system() call. This program is +necessary to allow some operating systems to run external programs as non-root. +.SH OPTIONS +.I shell-command + +.RS 3 +The shell command to execute. + +The command should have a fully-qualified path. +.RE +.SH ENVIRONMENT VARIABLES +The PATH variable set for the environment in which +.B smbrun +is executed will affect what executables are located and executed if a +fully-qualified path is not given in the command. + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the +.B smbrun +program be installed under the /usr/local hierarchy, in a directory readable +by all, writeable only by root. The program should be executable by all. +The program should NOT be setuid or setgid! +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the program has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B smbd(8), +.B smb.conf(8) +.SH DIAGNOSTICS +If smbrun cannot be located or cannot be executed by +.B smbd +then appropriate messages will be found in the smbd logs. Other diagnostics are +dependent on the shell-command being run. It is advisable for your shell +commands to issue suitable diagnostics to aid trouble-shooting. +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +This man page was written by Karl Auer (Karl.Auer@anu.edu.au) + +See +.B smb.conf(5) for a full list of contributors and details of how to +submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbstatus.1 samba-1.9.15p5/docs/smbstatus.1 --- last-version/docs/smbstatus.1 Sat Nov 4 23:20:23 1995 +++ samba-1.9.15p5/docs/smbstatus.1 Sun Dec 3 18:50:56 1995 @@ -48,5 +48,6 @@ .B smbd(8) See -.B smb.conf(5) for a full list of contributors and details on how to +.B smb.conf(5) +for a full list of contributors and details on how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/smbstatus.1.orig samba-1.9.15p5/docs/smbstatus.1.orig --- last-version/docs/smbstatus.1.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/smbstatus.1.orig Sat Nov 4 23:20:23 1995 @@ -0,0 +1,52 @@ +.TH SMBSTATUS 1 17/1/1995 smbstatus smbstatus +.SH NAME +smbstatus \- report on current Samba connections +.SH SYNOPSIS +.B smbstatus +[-d] +[-s +.I configuration file +] +.SH DESCRIPTION +This program is part of the Samba suite. + +.B smbstatus +is a very simple program to list the current Samba connections + +Just run the program and the output is self explanatory. You can offer +a configuration filename to override the default. The default is +CONFIGFILE from the Makefile. + +Option +.I -d +gives verbose output. + +.I -p +print a list of smbd processes and exit. Useful for scripting. + +.SH ENVIRONMENT VARIABLES +Not applicable. + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the +.B smbstatus +program be installed under the /usr/local hierarchy, in a directory readable +by all, writeable only by root. The program itself should be executable by all. + +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the program has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B smb.conf(5), +.B smbd(8) + +See +.B smb.conf(5) for a full list of contributors and details on how to +submit bug reports, comments etc. diff -u -r --new-file last-version/docs/testparm.1 samba-1.9.15p5/docs/testparm.1 --- last-version/docs/testparm.1 Wed Nov 22 22:28:28 1995 +++ samba-1.9.15p5/docs/testparm.1 Sun Dec 3 18:50:56 1995 @@ -100,5 +100,6 @@ (Karl.Auer@anu.edu.au) See -.B samba(7) for a full list of contributors and details on how to +.B samba(7) +for a full list of contributors and details on how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/testparm.1.orig samba-1.9.15p5/docs/testparm.1.orig --- last-version/docs/testparm.1.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/testparm.1.orig Wed Nov 22 22:28:28 1995 @@ -0,0 +1,104 @@ +.TH TESTPARM 1 17/1/1995 testparm testparm +.SH NAME +testparm \- check an smbd configuration file for internal correctness +.SH SYNOPSIS +.B testparm +[ +.I configfilename +[ +.I hostname +.I hostIP +] +] +.SH DESCRIPTION +This program is part of the Samba suite. + +.B testparm +is a very simple test program to check an +.B smbd +configuration +file for internal correctness. If this program reports no problems, you can use +the configuration file with confidence that smbd will successfully +load the configuration file. + +Note that this is NOT a guarantee that the services specified in the +configuration file will be available or will operate as expected. + +If the optional host name and host IP address are specified on the +command line, this test program will run through the service entries +reporting whether the specified host has access to each service. +.SH OPTIONS +.I configfilename + +.RS 3 +This is the name of the configuration file to check. +.RE + +.I hostname + +.RS 3 +This is the name of the host to check access on. + +If this parameter is supplied, the +.I hostIP +parameter must also be supplied, or strange things may happen. +.RE + +.I hostIP + +.RS 3 +This is the IP number of the host specified in the previous parameter. + +This number must be supplied if the +.I hostname +parameter is supplied, or strange things may happen. +.RE +.SH FILES +.B smb.conf +.RS 3 +This is usually the name of the configuration file used by smbd. +.RE +.SH ENVIRONMENT VARIABLES +Not applicable. + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the +.B testparm +program be installed under the /usr/local hierarchy, in a directory readable +by all, writeable only by root. The program itself should be executable by all. +The program should NOT be setuid or setgid! +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the program has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B smb.conf(5), +.B smbd(8) +.SH DIAGNOSTICS +The program will issue a message saying whether the configuration file loaded +OK or not. This message may be preceded by errors and warnings if the file +did not load. If the file was loaded OK, the program then dumps all known +service details to stdout. + +If a host name is specified but no host IP number, all bets are off. + +Other messages are self-explanatory. +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +The testparm program and this man page were written by Karl Auer +(Karl.Auer@anu.edu.au) + +See +.B samba(7) for a full list of contributors and details on how to +submit bug reports, comments etc. diff -u -r --new-file last-version/docs/testprns.1 samba-1.9.15p5/docs/testprns.1 --- last-version/docs/testprns.1 Wed Nov 22 22:28:34 1995 +++ samba-1.9.15p5/docs/testprns.1 Sun Dec 3 18:50:56 1995 @@ -103,5 +103,6 @@ (Karl.Auer@anu.edu.au) See -.B samba(7) for a full list of contributors and details of how to +.B samba(7) +for a full list of contributors and details of how to submit bug reports, comments etc. diff -u -r --new-file last-version/docs/testprns.1.orig samba-1.9.15p5/docs/testprns.1.orig --- last-version/docs/testprns.1.orig Thu Jan 1 10:00:00 1970 +++ samba-1.9.15p5/docs/testprns.1.orig Wed Nov 22 22:28:34 1995 @@ -0,0 +1,107 @@ +.TH TESTPRNS 1 17/1/1995 testprns testprns +.SH NAME +testprns \- check printer name for validity with smbd +.SH SYNOPSIS +.B testprns +.I printername +[ +.I printcapname +] +.SH DESCRIPTION +This program is part of the Samba suite. + +.B testprns +is a very simple test program to determine whether a given +printer name is valid for use in a service to be provided by +.B smbd. + +"Valid" in this context means "can be found in the printcap specified". This +program is very stupid - so stupid in fact that it would be wisest to always +specify the printcap file to use. +.SH OPTIONS +.I printername + +.RS 3 +The printer name to validate. + +Printer names are taken from the first field in each record in the printcap +file, single printer names and sets of aliases separated by vertical bars +("|") are recognised. Note that no validation or checking of the printcap +syntax is done beyond that required to extract the printer name. It may +be that the print spooling system is more forgiving or less forgiving +than +.B testprns +however if +.B testprns +finds the printer then smbd should do as well. + +.RE + +.I printcapname + +.RS 3 +This is the name of the printcap file to search for the given printer name +in. + +If no printcap name is specified, +.B testprns +will attempt to scan the printcap file specified at compile time +(PRINTCAP_NAME). +.RE +.SH FILES +.B /etc/printcap +.RS 3 +This is usually the default printcap file to scan. See +.B printcap(5)). +.RE +.SH ENVIRONMENT VARIABLES +Not applicable. + +.SH INSTALLATION +The location of the server and its support files is a matter for individual +system administrators. The following are thus suggestions only. + +It is recommended that the +.B testprns +program be installed under the /usr/local hierarchy, in a directory readable +by all, writeable only by root. The program should be executable by all. +The program should NOT be setuid or setgid! +.SH VERSION +This man page is (mostly) correct for version 1.9.00 of the Samba suite, plus some +of the recent patches to it. These notes will necessarily lag behind +development of the software, so it is possible that your version of +the program has extensions or parameter semantics that differ from or are not +covered by this man page. Please notify these to the address below for +rectification. +.SH SEE ALSO +.B printcap(5), +.B smbd(8), +.B smbclient(1) +.SH DIAGNOSTICS +If a printer is found to be valid, the message "Printer name <printername> is +valid" will be displayed. + +If a printer is found to be invalid, the message "Printer name <printername> +is not valid" will be displayed. + +All messages that would normally be logged during operation of smbd are +logged by this program to the file +.I test.log +in the current directory. The program runs at debuglevel 3, so quite extensive +logging information is written. The log should be checked carefully for errors +and warnings. + +Other messages are self-explanatory. +.SH BUGS +None known. +.SH CREDITS +The original Samba software and related utilities were created by +Andrew Tridgell (samba-bugs@anu.edu.au). Andrew is also the Keeper +of the Source for this project. + +The testprns program and this man page were written by Karl Auer +(Karl.Auer@anu.edu.au) + +See +.B samba(7) for a full list of contributors and details of how to +submit bug reports, comments etc. diff -u -r --new-file last-version/source/Makefile samba-1.9.15p5/source/Makefile --- last-version/source/Makefile Fri Nov 24 00:42:24 1995 +++ samba-1.9.15p5/source/Makefile Sun Dec 3 18:57:00 1995 @@ -117,7 +117,7 @@ # remotely (only works on some systems) # -DQUOTAS for quota support in disk_free(). This probably only works # on some systems. -# +# # NOTE: GETPWANAM & PWDAUTH are mutually exclusive, if you # Define one, you should NOT define the other. ##################################### @@ -426,8 +426,8 @@ LIBS = $(LIBS1) $(LIBSM) $(DCE_LIBS) $(DES_LIB) PROGS1 = smbd smbclient nmbd testparm testprns smbrun smbstatus smbpasswd -PROGS = $(PROGS1) nmblookup addtosmbpass -SCRIPTS = smbtar +PROGS = $(PROGS1) nmblookup +SCRIPTS = smbtar addtosmbpass all : CHECK $(PROGS) diff -u -r --new-file last-version/source/change-log samba-1.9.15p5/source/change-log --- last-version/source/change-log Fri Nov 24 23:20:15 1995 +++ samba-1.9.15p5/source/change-log Sun Dec 3 21:56:45 1995 @@ -1663,7 +1663,7 @@ - updated INSTALL.txt - hopefully fixed server level security with WfWg -2.0.0: +1.9.15 (patches): - major/minor fix for solaris from Jeroen Schipper <Jeroen.Schipper@let.ruu.nl> - fixed critical bug in directory listings @@ -1702,11 +1702,32 @@ - kanji patches from fujita@ainix.isac.co.jp (Takashi Fujita) - fixed bug handling non-encrypted passwords - released p4 - - + - fixed makefile for addtosmbpass + - DCE/DFS fixes from John Brezak (brezak@ch.hp.com) + - client patch for partial command matching from Andrew Wiseman + <bandc@dircon.co.uk> + - made is_8_3() handle full paths + - rewrote open_file_shared() with help from Charles Hoch + <hoch@hplcgh.hpl.hp.com> + - changed syslog to handle interactive programs + - fixed syslog problem with full path in argv[0] + - illegal name fixup for kanji from fujita@ainix.isac.co.jp + - fixed server level security to allow fallback to encryption + - changed reply_read() and reply_lockread() to ignore clients + smb_bufsize in order to handle broken lanman clients + - fixed NT wildcard problem with old style programs + - man page patches from "John M. Sellens" + <jmsellen@watdragon.uwaterloo.ca> + - partially documented the "character set" option + - changed default for MAXDIR to 64 + - changed default DPTR idle time to 120 + + ========== todo: +leftover lock files can end up belonging to non-smbd processes after a reboot. + hosts allow in nmbd hosts allow cache @@ -1724,20 +1745,15 @@ add option to print more info about locked files (full path, share name etc) -add masking to opendir? - -no refresh/reg of new IP? or send wack and challenge owner? +very slow listing CD, perhaps because of order of stat and readdir or add +masking to opendir? protocol drop back in client to avoid openX etc. -very slow listing CD, perhaps because of order of stat and readdir? - handle exported fat drives to a long filename capable client add check for existance of lpq commands etc (use stat?) -example showing popup on login containing "quota -v" - get rid of the silly +4 and -4 by removing NBT stuff write-only shares @@ -1748,18 +1764,17 @@ document homes behaviour with WinDD -apparently WfWg doesn't like the password server stuff in 1.9.14. Why? - add "hide file = *.o" "hide dir = .Foo*" "show file = xx*" type options. ALLOW_PASSWORD_CHANGE only compiles/works on some systems weird foooooooo/open.exe bug on NT -%a detection can't detect Win95 - -lpd stuff: - Tony Aiuto (tony@ics.com) - +%a detection can't detect Win95 versus WinNT +reverse mangled maps, so (*.html *.htm) works for new files. +install problems with w95. could be some sort of race? + +lpd stuff: + Tony Aiuto (tony@ics.com) diff -u -r --new-file last-version/source/charset.c samba-1.9.15p5/source/charset.c --- last-version/source/charset.c Thu Jun 29 18:17:35 1995 +++ samba-1.9.15p5/source/charset.c Sun Dec 3 19:26:29 1995 @@ -54,7 +54,7 @@ upper_char_map = &xx_upper_char_map[128]; lower_char_map = &xx_lower_char_map[128]; - for (i=-128;i<=127;i++) { + for (i= -128;i<=127;i++) { dos_char_map[(char)i] = 0; } @@ -63,7 +63,7 @@ add_dos_char(i,0); } - for (i=-128;i<=127;i++) { + for (i= -128;i<=127;i++) { char c = (char)i; upper_char_map[i] = lower_char_map[i] = c; if (isupper(c)) lower_char_map[c] = tolower(c); diff -u -r --new-file last-version/source/chgpasswd.c samba-1.9.15p5/source/chgpasswd.c --- last-version/source/chgpasswd.c Tue Jul 11 18:12:10 1995 +++ samba-1.9.15p5/source/chgpasswd.c Wed Nov 29 11:34:05 1995 @@ -18,6 +18,14 @@ * using it for any other reason are granted, so long as this disclaimer is left intact. */ +/* + This code was hacked considerably for inclusion in Samba, primarily + by Andrew.Tridgell@anu.edu.au. The biggest change was the addition + of the "password chat" option, which allows the easy runtime + specification of the expected sequence of events to change a + password. + */ + #include "includes.h" #include "loadparm.h" diff -u -r --new-file last-version/source/client.c samba-1.9.15p5/source/client.c --- last-version/source/client.c Thu Nov 23 11:13:47 1995 +++ samba-1.9.15p5/source/client.c Sun Dec 3 16:41:44 1995 @@ -36,6 +36,7 @@ pstring myname = ""; pstring password = ""; pstring username=""; +pstring workgroup=WORKGROUP; BOOL got_pass = False; BOOL connect_as_printer = False; BOOL connect_as_ipc = False; @@ -49,6 +50,9 @@ #define CLIENT_TIMEOUT (30*1000) #define SHORT_TIMEOUT (5*1000) +/* value for unused fid field in trans2 secondary request */ +#define FID_UNUSED (0xFFFF) + int name_type = 0x20; int max_protocol = PROTOCOL_NT1; @@ -146,6 +150,11 @@ static BOOL call_api(int prcnt,int drcnt,int mprcnt,int mdrcnt, int *rprcnt,int *rdrcnt,char *param,char *data, char **rparam,char **rdata); +static BOOL send_trans_request(char *outbuf,int trans, + char *name,int fid,int flags, + char *data,char *param,uint16 *setup, + int ldata,int lparam,int lsetup, + int mdata,int mparam,int msetup); /**************************************************************************** @@ -158,7 +167,7 @@ SSVAL(outbuf,smb_mid,mid); if (Protocol > PROTOCOL_CORE) { - CVAL(outbuf,smb_flg) = 0x8; + SCVAL(outbuf,smb_flg,0x8); SSVAL(outbuf,smb_flg2,0x1); } } @@ -257,7 +266,7 @@ bzero(outbuf,smb_size); set_message(outbuf,0,4 + strlen(path2),True); - CVAL(outbuf,smb_com) = SMBchkpth; + SCVAL(outbuf,smb_com,SMBchkpth); SSVAL(outbuf,smb_tid,cnum); setup_pkt(outbuf); @@ -800,18 +809,28 @@ } /**************************************************************************** - receive a SMB trans2 response allocating the necessary memory + receive a SMB trans or trans2 response allocating the necessary memory ****************************************************************************/ -static BOOL receive_trans2_response(char *inbuf,int *data_len,int *param_len, +static BOOL receive_trans_response(char *inbuf,int trans, + int *data_len,int *param_len, char **data,char **param) { int total_data=0; int total_param=0; + int this_data,this_param; *data_len = *param_len = 0; receive_smb(Client,inbuf,CLIENT_TIMEOUT); + show_msg(inbuf); + /* sanity check */ + if (CVAL(inbuf,smb_com) != trans) + { + DEBUG(0,("Expected %s response, got command 0x%02x\n", + trans==SMBtrans?"SMBtrans":"SMBtrans2", CVAL(inbuf,smb_com))); + return(False); + } if (CVAL(inbuf,smb_rcls) != 0) return(False); @@ -825,12 +844,18 @@ while (1) { - memcpy(*data + SVAL(inbuf,smb_drdisp),smb_base(inbuf) + SVAL(inbuf,smb_droff), - SVAL(inbuf,smb_drcnt)); - memcpy(*param + SVAL(inbuf,smb_prdisp),smb_base(inbuf) + SVAL(inbuf,smb_proff), - SVAL(inbuf,smb_prcnt)); - *data_len += SVAL(inbuf,smb_drcnt); - *param_len += SVAL(inbuf,smb_prcnt); + this_data = SVAL(inbuf,smb_drcnt); + this_param = SVAL(inbuf,smb_prcnt); + if (this_data) + memcpy(*data + SVAL(inbuf,smb_drdisp), + smb_base(inbuf) + SVAL(inbuf,smb_droff), + this_data); + if (this_param) + memcpy(*param + SVAL(inbuf,smb_prdisp), + smb_base(inbuf) + SVAL(inbuf,smb_proff), + this_param); + *data_len += this_data; + *param_len += this_param; /* parse out the total lengths again - they can shrink! */ total_data = SVAL(inbuf,smb_tdrcnt); @@ -838,7 +863,19 @@ if (total_data <= *data_len && total_param <= *param_len) break; + receive_smb(Client,inbuf,CLIENT_TIMEOUT); + show_msg(inbuf); + + /* sanity check */ + if (CVAL(inbuf,smb_com) != trans) + { + DEBUG(0,("Expected %s response, got command 0x%02x\n", + trans==SMBtrans?"SMBtrans":"SMBtrans2", CVAL(inbuf,smb_com))); + return(False); + } + if (CVAL(inbuf,smb_rcls) != 0) + return(False); } return(True); @@ -872,6 +909,9 @@ int ff_dir_handle=0; int loop_count = 0; + uint16 setup; + pstring param; + strcpy(mask,Mask); while (ff_eos == 0) @@ -883,67 +923,39 @@ break; } - bzero(outbuf,smb_setup); - set_message(outbuf,15,5 + 12 + strlen(mask)+1,True); - CVAL(outbuf,smb_com) = SMBtrans2; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - SSVAL(outbuf,smb_tpscnt,12 + strlen(mask)+1); - SSVAL(outbuf,smb_tdscnt,0); - SSVAL(outbuf,smb_mprcnt,10); - SSVAL(outbuf,smb_mdrcnt,0xFFFF); - SSVAL(outbuf,smb_msrcnt,0); - SSVAL(outbuf,smb_flags,0); - SIVAL(outbuf,smb_timeout,0); - SSVAL(outbuf,smb_pscnt,SVAL(outbuf,smb_tpscnt)); - SSVAL(outbuf,smb_psoff,smb_offset(smb_buf(outbuf)+3,outbuf)); - SSVAL(outbuf,smb_dscnt,0); - SSVAL(outbuf,smb_dsoff,0); - SSVAL(outbuf,smb_suwcnt,1); - - if (First) - SSVAL(outbuf,smb_setup0,TRANSACT2_FINDFIRST); - else - SSVAL(outbuf,smb_setup0,TRANSACT2_FINDNEXT); - - p = smb_buf(outbuf); - *p++ = 0; /* put in a null smb_name */ - *p++ = 'D'; *p++ = ' '; /* this was added because OS/2 does it */ - if (First) { - SSVAL(p,0,attribute); /* attribute */ - SSVAL(p,2,max_matches); /* max count */ - SSVAL(p,4,8+4+2); /* resume required + close on end + continue */ - SSVAL(p,6,info_level); - SIVAL(p,8,0); - p += 12; - strcpy(p,mask); - p += strlen(mask); - *p++ = 0; *p++ = 0; + setup = TRANSACT2_FINDFIRST; + SSVAL(param,0,attribute); /* attribute */ + SSVAL(param,2,max_matches); /* max count */ + SSVAL(param,4,8+4+2); /* resume required + close on end + continue */ + SSVAL(param,6,info_level); + SIVAL(param,8,0); + strcpy(param+12,mask); } else { + setup = TRANSACT2_FINDNEXT; + SSVAL(param,0,ff_dir_handle); + SSVAL(param,2,max_matches); /* max count */ + SSVAL(param,4,info_level); + SIVAL(param,6,ff_resume_key); /* ff_resume_key */ + SSVAL(param,10,8+4+2); /* resume required + close on end + continue */ + strcpy(param+12,mask); + DEBUG(5,("hand=0x%X resume=%d ff_lastname=%d mask=%s\n", ff_dir_handle,ff_resume_key,ff_lastname,mask)); - SSVAL(p,0,ff_dir_handle); - SSVAL(p,2,max_matches); /* max count */ - SSVAL(p,4,info_level); - SIVAL(p,6,ff_resume_key); /* ff_resume_key */ - SSVAL(p,10,8+4+2); /* resume required + close on end + continue */ - p += 12; - strcpy(p,mask); - *p++ = 0; *p++ = 0; } + /* ??? original code added 1 pad byte after param */ - send_smb(Client,outbuf); + send_trans_request(outbuf,SMBtrans2,NULL,FID_UNUSED,0, + NULL,param,&setup, + 0,12+strlen(mask)+1,1, + BUFFER_SIZE,10,0); - receive_trans2_response(inbuf, + if (!receive_trans_response(inbuf,SMBtrans2, &resp_data_len,&resp_param_len, - &resp_data,&resp_param); - - if (CVAL(inbuf,smb_rcls) != 0) + &resp_data,&resp_param)) { DEBUG(3,("FIND%s gave %s\n",First?"FIRST":"NEXT",smb_errstr(inbuf))); break; @@ -1144,7 +1156,7 @@ SSVAL(p,smb_wct,10); SSVAL(p,smb_vwv0,0xFF); SSVAL(p,smb_vwv5,MIN(max_xmit-500,finfo.size)); - SSVAL(p,smb_vwv9,MIN(0xFFFF,finfo.size)); + SSVAL(p,smb_vwv9,MIN(BUFFER_SIZE,finfo.size)); smb_setlen(outbuf,smb_len(outbuf)+11*2+1); } #endif @@ -1275,7 +1287,7 @@ SSVAL(outbuf,smb_vwv5,MIN(max_xmit-200,finfo.size - nread)); SSVAL(outbuf,smb_vwv6,0); SIVAL(outbuf,smb_vwv7,0); - SSVAL(outbuf,smb_vwv9,MIN(0xFFFF,finfo.size-nread)); + SSVAL(outbuf,smb_vwv9,MIN(BUFFER_SIZE,finfo.size-nread)); if (close_done) { @@ -1317,7 +1329,7 @@ /* use readbraw */ case 1: { - static int readbraw_size = 0xFFFF; + static int readbraw_size = BUFFER_SIZE; extern int Client; bzero(outbuf,smb_size); @@ -1905,7 +1917,7 @@ DEBUG(1,("putting file %s of size %d bytes as %s ",lname,finfo->size,CNV_LANG(rname))); if (!maxwrite) - maxwrite = writebraw_supported?MAX(max_xmit,0xFFFF):(max_xmit-200); + maxwrite = writebraw_supported?MAX(max_xmit,BUFFER_SIZE):(max_xmit-200); while (nread < finfo->size) { @@ -2152,7 +2164,9 @@ ****************************************************************************/ static void do_cancel(int job) { - char *p,*rparam,*rdata; + char *rparam = NULL; + char *rdata = NULL; + char *p; int rdrcnt,rprcnt; pstring param; @@ -2182,8 +2196,12 @@ printf("Error %d calcelling job %d\n",res,job); return; } - + else printf("Server refused cancel request\n"); + + if (rparam) free(rparam); + if (rdata) free(rdata); + return; } @@ -2219,54 +2237,31 @@ static void cmd_stat(char *inbuf,char *outbuf) { fstring buf; - pstring fname; + pstring param; char *resp_data=NULL; char *resp_param=NULL; int resp_data_len = 0; int resp_param_len=0; char *p; + uint16 setup = TRANSACT2_QPATHINFO; if (!next_token(NULL,buf,NULL)) { printf("stat <file>\n"); return; } - strcpy(fname,cur_dir); - strcat(fname,buf); - - bzero(outbuf,smb_setup); - set_message(outbuf,15,5 + 6 + strlen(fname)+1,True); - CVAL(outbuf,smb_com) = SMBtrans2; - SSVAL(outbuf,smb_tid,cnum); - setup_pkt(outbuf); - - SSVAL(outbuf,smb_tpscnt,6 + strlen(fname)+1); - SSVAL(outbuf,smb_tdscnt,0); - SSVAL(outbuf,smb_mprcnt,2); - SSVAL(outbuf,smb_mdrcnt,65535); - SSVAL(outbuf,smb_msrcnt,0); - SSVAL(outbuf,smb_flags,0); - SIVAL(outbuf,smb_timeout,0); - SSVAL(outbuf,smb_pscnt,SVAL(outbuf,smb_tpscnt)); - SSVAL(outbuf,smb_psoff,smb_offset(smb_buf(outbuf)+3,outbuf)); - SSVAL(outbuf,smb_dscnt,0); - SSVAL(outbuf,smb_dsoff,0); - SSVAL(outbuf,smb_suwcnt,1); - - SSVAL(outbuf,smb_setup0,TRANSACT2_QPATHINFO); - - p = smb_buf(outbuf); - *p++ = 0; /* put in a null smb_name */ - *p++ = 'D'; *p++ = ' '; /* this was added because OS/2 does it */ - - SSVAL(p,0,4); /* level */ - p += 6; - strcpy(p,fname); - p = skip_string(p,1); - - send_smb(Client,outbuf); + bzero(param,6); + SSVAL(param,0,4); /* level */ + p = param+6; + strcpy(p,cur_dir); + strcat(p,buf); + + send_trans_request(outbuf,SMBtrans2,NULL,FID_UNUSED,0, + NULL,param,&setup, + 0,6 + strlen(p)+1,1, + BUFFER_SIZE,2,0); - receive_trans2_response(inbuf, + receive_trans_response(inbuf,SMBtrans2, &resp_data_len,&resp_param_len, &resp_data,&resp_param); @@ -3095,7 +3090,7 @@ p = smb_buf(outbuf); memcpy(p,pword,passlen); p += SVAL(outbuf,smb_vwv7); strcpy(p,username);p = skip_string(p,1); - strcpy(p,WORKGROUP);p = skip_string(p,1); + strcpy(p,workgroup);p = skip_string(p,1); strcpy(p,"Unix");p = skip_string(p,1); strcpy(p,"Samba");p = skip_string(p,1); set_message(outbuf,13,PTR_DIFF(p,smb_buf(outbuf)),False); @@ -3279,69 +3274,150 @@ { static char *inbuf=NULL; static char *outbuf=NULL; - char *p1,*p2; if (!inbuf) inbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); if (!outbuf) outbuf = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); - /* send a SMBtrans command */ + send_trans_request(outbuf,SMBtrans,"\\PIPE\\LANMAN",0,0, + data,param,NULL, + drcnt,prcnt,0, + mdrcnt,mprcnt,0); + + return (receive_trans_response(inbuf,SMBtrans, + rdrcnt,rprcnt, + rdata,rparam)); +} + +/**************************************************************************** + send a SMB trans or trans2 request + ****************************************************************************/ +static BOOL send_trans_request(char *outbuf,int trans, + char *name,int fid,int flags, + char *data,char *param,uint16 *setup, + int ldata,int lparam,int lsetup, + int mdata,int mparam,int msetup) +{ + int i; + int this_ldata,this_lparam; + int tot_data=0,tot_param=0; + char *outdata,*outparam; + pstring inbuf; + char *p; + + this_lparam = MIN(lparam,max_xmit - (500+lsetup*SIZEOFWORD)); /* hack */ + this_ldata = MIN(ldata,max_xmit - (500+lsetup*SIZEOFWORD+this_lparam)); + bzero(outbuf,smb_size); - set_message(outbuf,14,0,True); - CVAL(outbuf,smb_com) = SMBtrans; + set_message(outbuf,14+lsetup,0,True); + CVAL(outbuf,smb_com) = trans; SSVAL(outbuf,smb_tid,cnum); setup_pkt(outbuf); - p1 = smb_buf(outbuf); - strcpy(p1,"\\PIPE\\LANMAN"); - p1 = skip_string(p1,1); - p2 = p1 + prcnt; - - if (prcnt > 0) - memcpy(p1,param,prcnt); - if (drcnt > 0) - memcpy(p2,data,drcnt); - - SSVAL(outbuf,smb_vwv0,prcnt); /* param count */ - SSVAL(outbuf,smb_vwv1,drcnt); /* data count */ - SSVAL(outbuf,smb_vwv2,mprcnt); /* mprcnt */ - SSVAL(outbuf,smb_vwv3,mdrcnt); /* mdrcnt */ - SSVAL(outbuf,smb_vwv4,0); /* msrcnt */ - SSVAL(outbuf,smb_vwv5,0); /* flags */ - SSVAL(outbuf,smb_vwv9,prcnt); /* pscnt */ - SSVAL(outbuf,smb_vwv10,smb_offset(p1,outbuf)); /* psoff */ - SSVAL(outbuf,smb_vwv11,drcnt); /* dscnt */ - SSVAL(outbuf,smb_vwv12,smb_offset(p2,outbuf)); /* dsoff */ - CVAL(outbuf,smb_vwv13) = 0; /* suwcnt */ + outparam = smb_buf(outbuf)+(trans==SMBtrans ? strlen(name)+1 : 3); + outdata = outparam+this_lparam; - set_message(outbuf,14,PTR_DIFF(p2+drcnt,smb_buf(outbuf)),False); + /* primary request */ + SSVAL(outbuf,smb_tpscnt,lparam); /* tpscnt */ + SSVAL(outbuf,smb_tdscnt,ldata); /* tdscnt */ + SSVAL(outbuf,smb_mprcnt,mparam); /* mprcnt */ + SSVAL(outbuf,smb_mdrcnt,mdata); /* mdrcnt */ + SCVAL(outbuf,smb_msrcnt,msetup); /* msrcnt */ + SSVAL(outbuf,smb_flags,flags); /* flags */ + SIVAL(outbuf,smb_timeout,0); /* timeout */ + SSVAL(outbuf,smb_pscnt,this_lparam); /* pscnt */ + SSVAL(outbuf,smb_psoff,smb_offset(outparam,outbuf)); /* psoff */ + SSVAL(outbuf,smb_dscnt,this_ldata); /* dscnt */ + SSVAL(outbuf,smb_dsoff,smb_offset(outdata,outbuf)); /* dsoff */ + SCVAL(outbuf,smb_suwcnt,lsetup); /* suwcnt */ + for (i=0;i<lsetup;i++) /* setup[] */ + SSVAL(outbuf,smb_setup+i*SIZEOFWORD,setup[i]); + p = smb_buf(outbuf); + if (trans==SMBtrans) + strcpy(p,name); /* name[] */ + else + { + *p++ = 0; /* put in a null smb_name */ + *p++ = 'D'; *p++ = ' '; /* this was added because OS/2 does it */ + } + if (this_lparam) /* param[] */ + memcpy(outparam,param,this_lparam); + if (this_ldata) /* data[] */ + memcpy(outdata,data,this_ldata); + set_message(outbuf,14+lsetup, /* wcnt, bcc */ + PTR_DIFF(outdata+this_ldata,smb_buf(outbuf)),False); + show_msg(outbuf); send_smb(Client,outbuf); - receive_smb(Client,inbuf,CLIENT_TIMEOUT); + + if (this_ldata < ldata || this_lparam < lparam) + { + /* receive interim response */ + if (!receive_smb(Client,inbuf,SHORT_TIMEOUT) || CVAL(inbuf,smb_rcls) != 0) + { + DEBUG(0,("%s request failed (%s)\n", + trans==SMBtrans?"SMBtrans":"SMBtrans2", smb_errstr(inbuf))); + return(False); + } + + tot_data = this_ldata; + tot_param = this_lparam; - if (CVAL(inbuf,smb_rcls) == 0) + while (tot_data < ldata || tot_param < lparam) { - if (rparam) - *rparam = inbuf+4 + SVAL(inbuf,smb_vwv4); - if (rdata) - *rdata = inbuf+4 + SVAL(inbuf,smb_vwv7); - if (rprcnt) - *rprcnt = SVAL(inbuf,smb_vwv3); - if (rdrcnt) - *rdrcnt = SVAL(inbuf,smb_vwv6); - return(True); + this_lparam = MIN(lparam-tot_param,max_xmit - 500); /* hack */ + this_ldata = MIN(ldata-tot_data,max_xmit - (500+this_lparam)); + + set_message(outbuf,trans==SMBtrans?8:9,0,True); + CVAL(outbuf,smb_com) = trans==SMBtrans ? SMBtranss : SMBtranss2; + + outparam = smb_buf(outbuf); + outdata = outparam+this_lparam; + + /* secondary request */ + SSVAL(outbuf,smb_tpscnt,lparam); /* tpscnt */ + SSVAL(outbuf,smb_tdscnt,ldata); /* tdscnt */ + SSVAL(outbuf,smb_spscnt,this_lparam); /* pscnt */ + SSVAL(outbuf,smb_spsoff,smb_offset(outparam,outbuf)); /* psoff */ + SSVAL(outbuf,smb_spsdisp,tot_param); /* psdisp */ + SSVAL(outbuf,smb_sdscnt,this_ldata); /* dscnt */ + SSVAL(outbuf,smb_sdsoff,smb_offset(outdata,outbuf)); /* dsoff */ + SSVAL(outbuf,smb_sdsdisp,tot_data); /* dsdisp */ + if (trans==SMBtrans2) + SSVAL(outbuf,smb_sfid,fid); /* fid */ + if (this_lparam) /* param[] */ + memcpy(outparam,param,this_lparam); + if (this_ldata) /* data[] */ + memcpy(outdata,data,this_ldata); + set_message(outbuf,trans==SMBtrans?8:9, /* wcnt, bcc */ + PTR_DIFF(outdata+this_ldata,smb_buf(outbuf)),False); + + show_msg(outbuf); + send_smb(Client,outbuf); + + tot_data += this_ldata; + tot_param += this_lparam; + } } - return(False); + return(True); } - /**************************************************************************** try and browse available connections on a host ****************************************************************************/ -static BOOL browse_host() +static BOOL browse_host(BOOL sort) { - char *p,*rparam,*rdata; +#ifdef NOSTRCASECMP +#define strcasecmp StrCaseCmp +#endif + extern int strcasecmp(); + + char *rparam = NULL; + char *rdata = NULL; + char *p; + int rdrcnt,rprcnt; pstring param; + int count = -1; /* now send a SMBtrans command with api RNetShareEnum */ p = param; @@ -3352,68 +3428,73 @@ strcpy(p,"B13BWz"); p = skip_string(p,1); SSVAL(p,0,1); - SSVAL(p,2,10000); + SSVAL(p,2,BUFFER_SIZE); p += 4; if (call_api(PTR_DIFF(p,param),0, - 1024,10000, - NULL,NULL, + 1024,BUFFER_SIZE, + &rprcnt,&rdrcnt, param,NULL, &rparam,&rdata)) { int res = SVAL(rparam,0); int converter=SVAL(rparam,2); - int count=SVAL(rparam,4); int i; BOOL long_share_name=False; - - if (res != 0) - return(False); - - p = rdata; - - if (count > 0) - { - printf("\n\tSharename Type Comment\n"); - printf("\t--------- ---- -------\n"); - } - - for (i=0;i<count;i++) + + if (res == 0) { - char *sname = p; - int type = SVAL(p,14); - int comment_offset = IVAL(p,16) & 0xFFFF; - fstring typestr=""; + count=SVAL(rparam,4); + p = rdata; - switch (type) + if (count > 0) { - case 0: - strcpy(typestr,"Disk"); break; - case 1: - strcpy(typestr,"Printer"); break; - case 2: - strcpy(typestr,"Device"); break; - case 3: - strcpy(typestr,"IPC"); break; + printf("\n\tSharename Type Comment\n"); + printf("\t--------- ---- -------\n"); } - printf("\t%-15.15s%-10.10s%s\n", - sname, - typestr, - comment_offset?rdata+comment_offset-converter:""); + if (sort) + qsort(p,count,20,QSORT_CAST strcasecmp); + + for (i=0;i<count;i++) + { + char *sname = p; + int type = SVAL(p,14); + int comment_offset = IVAL(p,16) & 0xFFFF; + fstring typestr=""; + + switch (type) + { + case STYPE_DISKTREE: + strcpy(typestr,"Disk"); break; + case STYPE_PRINTQ: + strcpy(typestr,"Printer"); break; + case STYPE_DEVICE: + strcpy(typestr,"Device"); break; + case STYPE_IPC: + strcpy(typestr,"IPC"); break; + } + + printf("\t%-15.15s%-10.10s%s\n", + sname, + typestr, + comment_offset?rdata+comment_offset-converter:""); - if (strlen(sname)>8) long_share_name=True; + if (strlen(sname)>8) long_share_name=True; - p += 20; - } - - if (long_share_name) { - printf("\nNOTE: There were share names longer than 8 chars.\nOn older clients these may not be accessible or may give browsing errors\n"); - } + p += 20; + } - if (count>0) return(True); + if (long_share_name) { + printf("\nNOTE: There were share names longer than 8 chars.\nOn older clients these may not be accessible or may give browsing errors\n"); + } + } } - return(False); + + if (rparam) free(rparam); + if (rdata) free(rdata); + + return(count>0); } @@ -3422,7 +3503,9 @@ ****************************************************************************/ static void server_info() { - char *p,*rparam,*rdata; + char *rparam = NULL; + char *rdata = NULL; + char *p; int rdrcnt,rprcnt; pstring param; @@ -3448,9 +3531,8 @@ int res = SVAL(rparam,0); int converter=SVAL(rparam,2); - if (res != 0) - return; - + if (res == 0) + { p = rdata; printf("\nServer=[%s] User=[%s] Workgroup=[%s] Domain=[%s]\n", @@ -3459,6 +3541,11 @@ rdata+SVAL(p,8)-converter, rdata+SVAL(p,14)-converter); } + } + + if (rparam) free(rparam); + if (rdata) free(rdata); + return; } @@ -3468,9 +3555,13 @@ ****************************************************************************/ static BOOL list_servers() { - char *p,*rparam,*rdata; + char *rparam = NULL; + char *rdata = NULL; + int rdrcnt,rprcnt; + char *p; pstring param; int uLevel = 1; + int count = -1; int servertype = SV_TYPE_ALL; @@ -3495,21 +3586,17 @@ if (call_api(PTR_DIFF(p,param),0, 8,10000, - NULL,NULL, + &rprcnt,&rdrcnt, param,NULL, &rparam,&rdata)) { int res = SVAL(rparam,0); int converter=SVAL(rparam,2); - int count=SVAL(rparam,4); int i; - if (res != 0) + if (res == 0) { - printf("\nThis machine does not have a browse list\n"); - return(False); - } - + count=SVAL(rparam,4); p = rdata; if (count > 0) @@ -3530,6 +3617,15 @@ p += 26; } } + else + { + printf("\nThis machine does not have a browse list\n"); + } + } + + if (rparam) free(rparam); + if (rdata) free(rdata); + return(True); } @@ -3574,6 +3670,7 @@ {"cancel",cmd_cancel,"<jobid> cancel a print queue entry"}, {"stat",cmd_stat,"<file> get info on a file (experimental!)"}, {"quit",send_logout,"logoff the server"}, + {"q",send_logout,"logoff the server"}, {"exit",send_logout,"logoff the server"}, {"newer",cmd_newer,"<file> only mget files newer than the specified local file"}, {"archive",cmd_archive,"<level>\n0=ignore archive bit\n1=only get archive files\n2=only get archive files and reset archive bit\n3=get all files and reset archive bit"}, @@ -3588,6 +3685,41 @@ {"",NULL,NULL} }; + +/******************************************************************* + lookup a command string in the list of commands, including + abbreviations + ******************************************************************/ +static int process_tok(fstring tok) +{ + int i = 0, matches = 0; + int cmd; + int tok_len = strlen(tok); + + while (commands[i].fn != NULL) + { + if (strequal(commands[i].name,tok)) + { + matches = 1; + cmd = i; + break; + } + else if (strnequal(commands[i].name, tok, tok_len+1)) + { + matches++; + cmd = i; + } + i++; + } + + if (matches == 0) + return(-1); + else if (matches == 1) + return(cmd); + else + return(-2); +} + /**************************************************************************** help ****************************************************************************/ @@ -3598,12 +3730,8 @@ if (next_token(NULL,buf,NULL)) { - while (commands[i].description) - { - if (strequal(commands[i].name,buf)) - DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description)); - i++; - } + if ((i = process_tok(buf)) >= 0) + DEBUG(0,("HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description)); } else while (commands[i].description) @@ -3765,7 +3893,7 @@ DEBUG(1,("Trying to re-open connection\n")); set_message(outbuf,0,0,True); - CVAL(outbuf,smb_com) = SMBtdis; + SCVAL(outbuf,smb_com,SMBtdis); SSVAL(outbuf,smb_tid,cnum); setup_pkt(outbuf); @@ -3783,6 +3911,7 @@ ****************************************************************************/ BOOL process(void ) { + extern FILE *dbf; pstring line; char *InBuffer = (char *)malloc(BUFFER_SIZE + SAFETY_MARGIN); @@ -3800,12 +3929,12 @@ { fstring tok; int i; - BOOL found = False; bzero(OutBuffer,smb_size); /* display a prompt */ DEBUG(1,("smb: %s> ", CNV_LANG(cur_dir))); + fflush(dbf); #ifdef CLIX line[0] = wait_keyboard(InBuffer); @@ -3839,18 +3968,12 @@ char *ptr = line; if (!next_token(&ptr,tok,NULL)) continue; } - - i = 0; - while (commands[i].fn != NULL) - { - if (strequal(commands[i].name,tok)) - { - found = True; - commands[i].fn(InBuffer,OutBuffer); - } - i++; - } - if (!found) + + if ((i = process_tok(tok)) >= 0) + commands[i].fn(InBuffer,OutBuffer); + else if (i == -2) + DEBUG(0,("%s: command abbreviation ambiguous\n",CNV_LANG(tok))); + else DEBUG(0,("%s: command not found\n",CNV_LANG(tok))); } @@ -3884,6 +4007,7 @@ DEBUG(0,("\t-I dest IP use this IP to connect to\n")); DEBUG(0,("\t-E write messages to stderr instead of stdout\n")); DEBUG(0,("\t-U username set the network username\n")); + DEBUG(0,("\t-W workgroup set the workgroup name\n")); #ifdef KANJI DEBUG(0,("\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n")); #endif /* KANJI */ @@ -3908,8 +4032,9 @@ *query_host = 0; DEBUGLEVEL = 2; - dbf = stdout; + setup_logging(pname,True); + TimeInit(); charset_initialise(); @@ -3973,9 +4098,9 @@ #ifdef KANJI setup_term_code (KANJI); - while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:")) != EOF) + while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:t:m:W:")) != EOF) #else - while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:")) != EOF) + while ((opt = getopt (argc, argv, "O:M:i:Nn:d:Pp:l:hI:EB:U:L:m:W:")) != EOF) #endif /* KANJI */ switch (opt) { @@ -4012,6 +4137,9 @@ } break; + case 'W': + strcpy(workgroup,optarg); + break; case 'E': dbf = stderr; break; @@ -4100,9 +4228,9 @@ return(1); server_info(); - if (!browse_host()) { + if (!browse_host(True)) { sleep(1); - browse_host(); + browse_host(True); } list_servers(); diff -u -r --new-file last-version/source/clitar.c samba-1.9.15p5/source/clitar.c --- last-version/source/clitar.c Thu Nov 23 10:07:28 1995 +++ samba-1.9.15p5/source/clitar.c Thu Nov 30 09:35:34 1995 @@ -27,8 +27,8 @@ extern BOOL reopen_connection(char *inbuf,char *outbuf); extern void do_dir(char *inbuf,char *outbuf,char *Mask,int attribute,void (*fn)(),BOOL recurse_dir); +extern BOOL recurse; - #define SEPARATORS " \t\n\r" extern int DEBUGLEVEL; extern int Client; @@ -772,7 +772,7 @@ strcat(mtar_mask,"*.*"); do_dir((char *)inbuf,(char *)outbuf, - mtar_mask,aSYSTEM | aHIDDEN | aDIR,do_tar,False); + mtar_mask,aSYSTEM | aHIDDEN | aDIR,do_tar,recurse); strcpy(cur_dir,saved_curdir); free(inbuf);free(outbuf); } @@ -1402,7 +1402,7 @@ else strcat(tarmac,"*.*"); - do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,False); + do_dir((char *)inbuf,(char *)outbuf,tarmac,attribute,do_tar,recurse); if (ntarf) dotareof(tarhandle); close(tarhandle); diff -u -r --new-file last-version/source/dir.c samba-1.9.15p5/source/dir.c --- last-version/source/dir.c Fri Nov 10 11:18:03 1995 +++ samba-1.9.15p5/source/dir.c Sun Dec 3 19:26:50 1995 @@ -94,7 +94,7 @@ { int i; uint32 old=dircounter+1; - int oldi=-1; + int oldi= -1; for (i=0;i<NUMDIRPTRS;i++) if (dirptrs[i].valid && dirptrs[i].ptr && dirptrs[i].lastused < old) { old = dirptrs[i].lastused; @@ -282,7 +282,7 @@ /* as a 2nd option, grab the oldest not marked for expect_close */ if (i == -1) { old=dircounter+1; - oldi=-1; + oldi= -1; for (i=0;i<NUMDIRPTRS;i++) if (!dirptrs[i].expect_close && dirptrs[i].lastused < old) { old = dirptrs[i].lastused; @@ -294,7 +294,7 @@ /* a 3rd option - grab the oldest one */ if (i == -1) { old=dircounter+1; - oldi=-1; + oldi= -1; for (i=0;i<NUMDIRPTRS;i++) if (dirptrs[i].lastused < old) { old = dirptrs[i].lastused; diff -u -r --new-file last-version/source/ipc.c samba-1.9.15p5/source/ipc.c --- last-version/source/ipc.c Thu Nov 23 14:28:05 1995 +++ samba-1.9.15p5/source/ipc.c Sun Dec 3 00:17:42 1995 @@ -55,11 +55,6 @@ #define ACCESS_WRITE 0x02 #define ACCESS_CREATE 0x04 -#define STYPE_DISKTREE 0 /* Disk drive */ -#define STYPE_PRINTQ 1 /* Spooler queue */ -#define STYPE_DEVICE 2 /* Serial device */ -#define STYPE_IPC 3 /* Interprocess communication (IPC) */ - #define SHPWLEN 8 /* share password length */ #define NNLEN 12 /* 8.3 net name length */ #define SNLEN 15 /* service name length */ @@ -916,7 +911,8 @@ if (!prefix_ok(str1,"WrLehD")) return False; if (!check_server_info(uLevel,str2)) return False; - total = get_server_info(servertype,&servers); + if (lp_browse_list()) + total = get_server_info(servertype,&servers); data_len = fixed_len = string_len = 0; diff -u -r --new-file last-version/source/loadparm.c samba-1.9.15p5/source/loadparm.c --- last-version/source/loadparm.c Thu Nov 23 13:35:22 1995 +++ samba-1.9.15p5/source/loadparm.c Sun Dec 3 00:17:01 1995 @@ -158,6 +158,7 @@ BOOL bReadPrediction; BOOL bReadbmpx; BOOL bSyslogOnly; + BOOL bBrowseList; } global; static global Globals; @@ -407,6 +408,7 @@ {"preferred master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, {"prefered master", P_BOOL, P_GLOBAL, &Globals.bPreferredMaster, NULL}, {"domain master", P_BOOL, P_GLOBAL, &Globals.bDomainMaster, NULL}, + {"browse list", P_BOOL, P_GLOBAL, &Globals.bBrowseList, NULL}, {"-valid", P_BOOL, P_LOCAL, &sDefault.valid, NULL}, {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL}, @@ -556,6 +558,7 @@ Globals.max_ttl = 60*60*4; /* 2 hours default */ Globals.bPreferredMaster = True; Globals.bDomainMaster = False; + Globals.bBrowseList = True; #ifdef KANJI coding_system = interpret_coding_system (KANJI, SJIS_CODE); @@ -678,6 +681,7 @@ FN_GLOBAL_BOOL(lp_strip_dot,&Globals.bStripDot) FN_GLOBAL_BOOL(lp_encrypted_passwords,&Globals.bEncryptPasswords) FN_GLOBAL_BOOL(lp_syslog_only,&Globals.bSyslogOnly) +FN_GLOBAL_BOOL(lp_browse_list,&Globals.bBrowseList) FN_GLOBAL_INTEGER(lp_os_level,&Globals.os_level) FN_GLOBAL_INTEGER(lp_max_ttl,&Globals.max_ttl) @@ -1199,8 +1203,8 @@ #ifdef KANJI /*************************************************************************** -handle the interpretation of the conding system parameter -***************************************************************************/ + handle the interpretation of the coding system parameter + *************************************************************************/ static BOOL handle_coding_system(char *pszParmValue,int *val) { *val = interpret_coding_system(pszParmValue,*val); diff -u -r --new-file last-version/source/loadparm.h samba-1.9.15p5/source/loadparm.h --- last-version/source/loadparm.h Thu Nov 23 11:18:52 1995 +++ samba-1.9.15p5/source/loadparm.h Sun Dec 3 00:17:16 1995 @@ -76,6 +76,7 @@ extern BOOL lp_strip_dot(void); extern BOOL lp_encrypted_passwords(void); extern BOOL lp_syslog_only(void); +extern BOOL lp_browse_list(void); extern int lp_numservices(void); extern int lp_keepalive(void); extern int lp_passwordlevel(void); diff -u -r --new-file last-version/source/local.h samba-1.9.15p5/source/local.h --- last-version/source/local.h Sat Nov 11 16:59:22 1995 +++ samba-1.9.15p5/source/local.h Sun Dec 3 21:42:38 1995 @@ -38,7 +38,7 @@ /* max number of directories open at once */ /* note that with the new directory code this no longer requires a file handle per directory, but large numbers do use more memory */ -#define MAXDIR 120 +#define MAXDIR 64 #define WORDMAX 0xFFFF @@ -118,7 +118,7 @@ #define SHARE_MODES_CHECK (10) #define SHARE_MODES_CLEAN (300) #define IDLE_CLOSED_TIMEOUT (30) -#define DPTR_IDLE_TIMEOUT (300) +#define DPTR_IDLE_TIMEOUT (120) #define SMBD_SELECT_LOOP (10) #define NMBD_SELECT_LOOP (10) #define BROWSE_INTERVAL (60) diff -u -r --new-file last-version/source/locking.c samba-1.9.15p5/source/locking.c --- last-version/source/locking.c Sat Nov 4 22:03:18 1995 +++ samba-1.9.15p5/source/locking.c Sat Dec 2 18:36:23 1995 @@ -97,80 +97,58 @@ } /******************************************************************* -name a share file -********************************************************************/ -static BOOL share_name(int fnum,char *name) + name a share file + ******************************************************************/ +static BOOL share_name(int cnum,struct stat *st,char *name) { - struct stat st; strcpy(name,lp_lockdir()); - standard_sub(Files[fnum].cnum,name); + standard_sub(cnum,name); trim_string(name,"","/"); if (!*name) return(False); name += strlen(name); - if (fstat(Files[fnum].fd,&st) == -1) - return(False); - - sprintf(name,"/share.%d.%d",(int)st.st_dev,(int)st.st_ino); + sprintf(name,"/share.%d.%d",(int)st->st_dev,(int)st->st_ino); return(True); } /******************************************************************* -get the share mode of a file -********************************************************************/ -int get_share_mode(int fnum,int *pid) + use the fnum to get the share file name + ******************************************************************/ +static BOOL share_name_fnum(int fnum,char *name) { - pstring fname; - int fd2; - char buf[16]; - int ret; - time_t t; - - *pid = 0; - - if (!share_name(fnum,fname)) return(0); - - fd2 = open(fname,O_RDONLY,0); - if (fd2 < 0) return(0); - - if (read(fd2,buf,16) != 16) { - close(fd2); - unlink(fname); - return(0); - } - close(fd2); - - t = IVAL(buf,0); - ret = IVAL(buf,4); - *pid = IVAL(buf,8); - - if (IVAL(buf,12) != LOCKING_VERSION) { - if (!unlink(fname)) DEBUG(2,("Deleted old locking file %s",fname)); - *pid = 0; - return(0); - } + struct stat st; + if (fstat(Files[fnum].fd,&st) != 0) return(False); + return(share_name(Files[fnum].cnum,&st,name)); +} - if (*pid && !process_exists(*pid)) { - ret=0; - *pid = 0; - } - if (! *pid) unlink(fname); /* XXXXX race, race */ +/******************************************************************* + get the share mode of a file using the fnum + ******************************************************************/ +int get_share_mode_by_fnum(int cnum,int fnum,int *pid) +{ + struct stat sbuf; + if (fstat(Files[fnum].fd,&sbuf) == -1) return(0); + return(get_share_mode(cnum,&sbuf,pid)); +} - if (*pid) - DEBUG(5,("Read share file %s mode 0x%X pid=%d\n",fname,ret,*pid)); +/******************************************************************* + get the share mode of a file using the files name + ******************************************************************/ +int get_share_mode_byname(int cnum,char *fname,int *pid) +{ + struct stat sbuf; + if (stat(fname,&sbuf) == -1) return(0); + return(get_share_mode(cnum,&sbuf,pid)); +} - return(ret); -} /******************************************************************* -get the share mode of a file using the files name +get the share mode of a file ********************************************************************/ -int get_share_mode_byname(int cnum,char *fname,int *pid) +int get_share_mode(int cnum,struct stat *sbuf,int *pid) { - struct stat st; - pstring lname; - char *name; + pstring fname; int fd2; char buf[16]; int ret; @@ -178,25 +156,14 @@ *pid = 0; - name = lname; - - strcpy(name,lp_lockdir()); - standard_sub(cnum,name); - trim_string(name,"","/"); - if (!*name) return(0); - name += strlen(name); - - if (stat(fname,&st) == -1) - return(0); - - sprintf(name,"/share.%d.%d",(int)st.st_dev,(int)st.st_ino); + if (!share_name(cnum,sbuf,fname)) return(0); - fd2 = open(lname,O_RDONLY,0); + fd2 = open(fname,O_RDONLY,0); if (fd2 < 0) return(0); if (read(fd2,buf,16) != 16) { close(fd2); - unlink(lname); + unlink(fname); return(0); } close(fd2); @@ -206,7 +173,7 @@ *pid = IVAL(buf,8); if (IVAL(buf,12) != LOCKING_VERSION) { - if (!unlink(lname)) DEBUG(2,("Deleted old locking file %s",lname)); + if (!unlink(fname)) DEBUG(2,("Deleted old locking file %s",fname)); *pid = 0; return(0); } @@ -216,10 +183,10 @@ *pid = 0; } - if (! *pid) unlink(lname); /* XXXXX race, race */ + if (! *pid) unlink(fname); /* XXXXX race, race */ if (*pid) - DEBUG(5,("Read share file %s mode 0x%X pid=%d\n",lname,ret,*pid)); + DEBUG(5,("Read share file %s mode 0x%X pid=%d\n",fname,ret,*pid)); return(ret); } @@ -237,7 +204,7 @@ int pid=0; BOOL del = False; - if (!share_name(fnum,fname)) return; + if (!share_name_fnum(fnum,fname)) return; fd2 = open(fname,O_RDONLY,0); if (fd2 < 0) return; @@ -279,7 +246,7 @@ char buf[16]; int pid = (int)getpid(); - if (!share_name(fnum,fname)) return(False); + if (!share_name_fnum(fnum,fname)) return(False); { int old_umask = umask(0); diff -u -r --new-file last-version/source/mangle.c samba-1.9.15p5/source/mangle.c --- last-version/source/mangle.c Fri Nov 24 14:55:22 1995 +++ samba-1.9.15p5/source/mangle.c Sun Dec 3 19:29:18 1995 @@ -83,9 +83,14 @@ BOOL is_8_3(char *fname) { int len = strlen(fname); - char *dot_pos = strchr(fname,'.'); + char *dot_pos; + char *slash_pos = strrchr(fname,'/'); int l; + if (slash_pos) fname = slash_pos+1; + + dot_pos = strchr(fname,'.'); + DEBUG(5,("checking %s for 8.3\n",fname)); if (case_mangle) @@ -238,10 +243,12 @@ { int i; pstring tmpname; - char extension[5]=""; + char extension[5]; char *p = strrchr(s,'.'); BOOL check_extension = False; + extension[0] = 0; + if (!mangled_stack) return(False); if (p) @@ -468,11 +475,14 @@ { int csum = str_checksum(s); char *p; - char extension[4] = ""; - char base[9]=""; + char extension[4]; + char base[9]; int baselen = 0; int extlen = 0; + extension[0]=0; + base[0]=0; + p = strrchr(s,'.'); if (p && (strlen(p+1)<4) ) { @@ -549,8 +559,21 @@ illegal[*s] = True; } +#ifdef KANJI + for (s = (unsigned char *)name; *s;) { + if (is_shift_jis (*s)) { + s += 2; + } else if (illegal[*s]) { + return(True); + } else { + s++; + } + } +#else for (s = (unsigned char *)name;*s;s++) if (illegal[*s]) return(True); +#endif + return(False); } diff -u -r --new-file last-version/source/nameserv.c samba-1.9.15p5/source/nameserv.c --- last-version/source/nameserv.c Fri Nov 24 14:28:09 1995 +++ samba-1.9.15p5/source/nameserv.c Sat Dec 2 19:28:23 1995 @@ -2080,9 +2080,7 @@ TimeInit(); -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif + setup_logging(argv[0],False); charset_initialise(); diff -u -r --new-file last-version/source/nmblookup.c samba-1.9.15p5/source/nmblookup.c --- last-version/source/nmblookup.c Thu Nov 23 11:14:01 1995 +++ samba-1.9.15p5/source/nmblookup.c Sun Dec 3 19:27:46 1995 @@ -36,7 +36,7 @@ static BOOL got_bcast = False; -int ServerFD=-1; +int ServerFD= -1; /**************************************************************************** open the socket communication @@ -113,7 +113,6 @@ int opt; unsigned int lookup_type = 0x20; pstring lookup; - extern FILE *dbf; extern int optind; extern char *optarg; BOOL find_master=False; @@ -124,13 +123,10 @@ *lookup = 0; TimeInit(); - charset_initialise(); -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif + setup_logging(argv[0],True); - dbf = stdout; + charset_initialise(); while ((opt = getopt(argc, argv, "p:d:B:i:SMh")) != EOF) switch (opt) diff -u -r --new-file last-version/source/password.c samba-1.9.15p5/source/password.c --- last-version/source/password.c Fri Nov 24 23:19:53 1995 +++ samba-1.9.15p5/source/password.c Sun Dec 3 19:27:35 1995 @@ -26,8 +26,13 @@ extern int Protocol; /* users from session setup */ -pstring session_users=""; +static pstring session_users=""; +/* these are kept here to keep the string_combinations function simple */ +static char this_user[100]=""; +static char this_salt[100]=""; +static char this_crypted[100]=""; + #ifdef SMB_PASSWD /* Data to do lanman1/2 password challenge. */ static unsigned char saved_challenge[8]; @@ -53,6 +58,16 @@ } /******************************************************************* +set the last challenge sent, usually from a password server +********************************************************************/ +BOOL set_challenge(char *challenge) +{ + memcpy(saved_challenge,challenge,8); + challenge_sent = True; + return(True); +} + +/******************************************************************* get the last challenge sent ********************************************************************/ BOOL last_challenge(char *challenge) @@ -333,13 +348,15 @@ #ifdef DFS_AUTH + +sec_login_handle_t my_dce_sec_context; +int dcelogin_atmost_once = 0; + /******************************************************************* check on a DCE/DFS authentication ********************************************************************/ static BOOL dfs_auth(char *this_user,char *password) { - static sec_login_handle_t my_dce_sec_context; - static int dcelogin_atmost_once = 0; error_status_t err; int err2; int prterr; @@ -394,7 +411,7 @@ dce_error_inq_text(err, dce_errstr, &err2); DEBUG(0,("DCE login failed for principal %s, cant set context: %s\n", this_user,dce_errstr)); - sec_login_purge_context(my_dce_sec_context, &err2); + sec_login_purge_context(my_dce_sec_context, &err); return(False); } else @@ -406,6 +423,22 @@ dcelogin_atmost_once = 1; return (True); } + +void dfs_unlogin(void) +{ + error_status_t err; + int err2; + unsigned char dce_errstr[dce_c_error_string_len]; + + sec_login_purge_context(my_dce_sec_context, &err); + if (err != error_status_ok ) + { + dce_error_inq_text(err, dce_errstr, &err2); + DEBUG(0,("DCE purge login context failed for server instance %d: %s\n", + getpid(), dce_errstr)); + } +} + #endif @@ -482,11 +515,6 @@ } -/* these are kept here to keep the string_combinations function simple */ -char this_user[100]=""; -char this_salt[100]=""; -char this_crypted[100]=""; - /**************************************************************************** core of password checking routine @@ -1215,7 +1243,7 @@ if (password_client >= 0) { close(password_client); - password_client=-1; + password_client= -1; } if (Protocol < PROTOCOL_NT1) { @@ -1294,13 +1322,13 @@ if (!ret || CVAL(inbuf,smb_rcls) || SVAL(inbuf,smb_vwv0)) { DEBUG(1,("%s rejected the protocol\n",pserver)); - close(password_client); password_client=-1; + close(password_client); password_client= -1; return(False); } if (!(CVAL(inbuf,smb_vwv1) & 1)) { DEBUG(1,("%s isn't in user level security mode\n",pserver)); - close(password_client); password_client=-1; + close(password_client); password_client= -1; return(False); } @@ -1354,7 +1382,7 @@ DEBUG(3,("password server %s accepted the password\n",pserver)); #ifndef KEEP_PASSWORD_SERVER_OPEN - close(password_client); password_client=-1; + close(password_client); password_client= -1; #endif return(True); diff -u -r --new-file last-version/source/printing.c samba-1.9.15p5/source/printing.c --- last-version/source/printing.c Sun Nov 12 12:06:48 1995 +++ samba-1.9.15p5/source/printing.c Sun Dec 3 19:28:08 1995 @@ -70,8 +70,7 @@ /* look for "%s" in the string. If there is no %s, we cannot print. */ if (!strstr(syscmd, "%s") && !strstr(syscmd, "%f")) { - DEBUG(2,("WARNING! No placeholder for the filename in the print command " - "for service %s!\n", SERVICE(snum))); + DEBUG(2,("WARNING! No placeholder for the filename in the print command for service %s!\n", SERVICE(snum))); } if (strstr(syscmd,"%s")) { diff -u -r --new-file last-version/source/reply.c samba-1.9.15p5/source/reply.c --- last-version/source/reply.c Wed Nov 22 21:35:16 1995 +++ samba-1.9.15p5/source/reply.c Sun Dec 3 19:27:15 1995 @@ -43,7 +43,7 @@ /* this macro should always be used to extract an fnum (smb_fid) from a packet to ensure chaining works correctly */ -#define GETFNUM(buf,where) (chain_fnum!=-1?chain_fnum:SVAL(buf,where)) +#define GETFNUM(buf,where) (chain_fnum!= -1?chain_fnum:SVAL(buf,where)) /**************************************************************************** @@ -637,7 +637,7 @@ int status_len; char *path; char status[21]; - int dptr_num=-1; + int dptr_num= -1; BOOL check_descend = False; BOOL expect_close = False; BOOL can_open = True; @@ -853,7 +853,7 @@ int status_len; char *path; char status[21]; - int dptr_num=-1; + int dptr_num= -1; cnum = SVAL(inbuf,smb_tid); @@ -1365,7 +1365,7 @@ /**************************************************************************** reply to a lockread (core+ protocol) ****************************************************************************/ -int reply_lockread(char *inbuf,char *outbuf,int length,int bufsize) +int reply_lockread(char *inbuf,char *outbuf) { int cnum,fnum; int nread = -1; @@ -1386,7 +1386,7 @@ startpos = IVAL(inbuf,smb_vwv2); outsize = set_message(outbuf,5,3,True); - numtoread = MIN(bufsize-outsize,numtoread); + numtoread = MIN(BUFFER_SIZE-outsize,numtoread); data = smb_buf(outbuf) + 3; if(!do_lock( fnum, cnum, numtoread, startpos, &eclass, &ecode)) @@ -1411,7 +1411,7 @@ /**************************************************************************** reply to a read ****************************************************************************/ -int reply_read(char *inbuf,char *outbuf,int length,int bufsize) +int reply_read(char *inbuf,char *outbuf) { int cnum,numtoread,fnum; int nread = 0; @@ -1430,7 +1430,7 @@ startpos = IVAL(inbuf,smb_vwv2); outsize = set_message(outbuf,5,3,True); - numtoread = MIN(bufsize-outsize,numtoread); + numtoread = MIN(BUFFER_SIZE-outsize,numtoread); data = smb_buf(outbuf) + 3; if (is_locked(fnum,cnum,numtoread,startpos)) @@ -1515,7 +1515,7 @@ /**************************************************************************** reply to a writebraw (core+ or LANMAN1.0 protocol) ****************************************************************************/ -int reply_writebraw(char *inbuf,char *outbuf,int length,int bufsize) +int reply_writebraw(char *inbuf,char *outbuf) { int nwritten=0; int total_written=0; @@ -1527,9 +1527,6 @@ BOOL write_through; int tcount; - /* this is just to stop silly warnings */ - length = bufsize = 0; - cnum = SVAL(inbuf,smb_tid); fnum = GETFNUM(inbuf,smb_vwv0); @@ -1825,7 +1822,7 @@ { int cnum,fnum; uint32 startpos; - int32 res=-1; + int32 res= -1; int mode,umode; int outsize = 0; @@ -2335,7 +2332,7 @@ { pstring directory; int cnum; - int outsize,ret=-1; + int outsize,ret= -1; strcpy(directory,smb_buf(inbuf) + 1); cnum = SVAL(inbuf,smb_tid); diff -u -r --new-file last-version/source/reply.h samba-1.9.15p5/source/reply.h --- last-version/source/reply.h Wed Nov 22 21:52:38 1995 +++ samba-1.9.15p5/source/reply.h Sun Dec 3 11:57:49 1995 @@ -22,10 +22,10 @@ int reply_ctemp(char *inbuf,char *outbuf); int reply_unlink(char *inbuf,char *outbuf); int reply_readbraw(char *inbuf, char *outbuf); -int reply_lockread(char *inbuf,char *outbuf,int length,int bufsize); -int reply_read(char *inbuf,char *outbuf,int length,int bufsize); +int reply_lockread(char *inbuf,char *outbuf); +int reply_read(char *inbuf,char *outbuf); int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize); -int reply_writebraw(char *inbuf,char *outbuf,int length,int bufsize); +int reply_writebraw(char *inbuf,char *outbuf); int reply_writeunlock(char *inbuf,char *outbuf); int reply_write(char *inbuf,char *outbuf,int dum1,int dum2); int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize); diff -u -r --new-file last-version/source/server.c samba-1.9.15p5/source/server.c --- last-version/source/server.c Thu Nov 23 11:03:36 1995 +++ samba-1.9.15p5/source/server.c Sun Dec 3 19:26:05 1995 @@ -95,6 +95,7 @@ #ifdef SMB_PASSWD extern void generate_next_challenge(char *challenge); +extern void set_challenge(char *challenge); #endif /* for readability... */ @@ -1190,31 +1191,45 @@ return(False); } +/**************************************************************************** + C. Hoch 11/22/95 + Helper for open_file_shared. + Truncate a file after checking locking; close file if locked. + **************************************************************************/ +static void truncate_unless_locked(int fnum, int cnum) +{ + if (Files[fnum].can_write){ + if (is_locked(fnum,cnum,0x3FFFFFFF,0)){ + close_file(fnum); + errno = EACCES; + unix_ERR_class = ERRDOS; + unix_ERR_code = ERRlock; + } + else + ftruncate(Files[fnum].fd,0); + } +} + /**************************************************************************** open a file with a share mode ****************************************************************************/ -void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun,int mode,int *Access,int *action) +void open_file_shared(int fnum,int cnum,char *fname,int share_mode,int ofun, + int mode,int *Access,int *action) { int flags=0; int flags2=0; - int old_share=0; int deny_mode = (share_mode>>4)&7; - int open_mode = share_mode&0xF; - int old_deny_mode; - int old_open_mode; - int access_allowed; struct stat sbuf; BOOL file_existed = file_exist(fname,&sbuf); - int share_pid=0; BOOL fcbopen = False; + int share_pid=0; Files[fnum].open = False; Files[fnum].fd = -1; /* this is for OS/2 EAs - try and say we don't support them */ if (strstr(fname,".+,;=[].")) { - /* errno = ENOENT; */ unix_ERR_class = ERRDOS; unix_ERR_code = ERROR_EAS_NOT_SUPPORTED; return; @@ -1230,44 +1245,26 @@ if ((ofun & 0x3) == 2) flags2 |= O_TRUNC; -#if 0 - /* append does not mean the same thing under dos and unix */ - if ((ofun & 0x3) == 1) - flags2 |= O_APPEND; -#endif + /* note that we ignore the append flag as + append does not mean the same thing under dos and unix */ - { - int open_mode2=open_mode; - switch (open_mode) - { - case 1: - open_mode2 = 1; - flags = O_WRONLY; - *Access = 1; - break; - case 0xF: /* XXXX - need to handle FCB open */ - case 2: - if (open_mode == 0xF) - fcbopen = True; - open_mode2 = 2; - flags = O_RDWR; - *Access = 2; - break; - default: - open_mode2 = 0; - flags = O_RDONLY; - *Access = 0; - break; - } - open_mode = open_mode2; - } + switch (share_mode&0xF) + { + case 1: + flags = O_WRONLY; + break; + case 0xF: + fcbopen = True; + flags = O_RDWR; + break; + case 2: + flags = O_RDWR; + break; + default: + flags = O_RDONLY; + break; + } - if (deny_mode > DENY_NONE && deny_mode!=DENY_FCB) { - DEBUG(2,("Invalid deny mode %d on file %s\n",deny_mode,fname)); - errno = EACCES; - return; - } - if (flags != O_RDONLY && file_existed && (!CAN_WRITE(cnum) || IS_DOS_READONLY(dos_mode(cnum,fname,&sbuf)))) { if (!fcbopen) { @@ -1275,112 +1272,127 @@ return; } flags = O_RDONLY; - *Access = 0; - open_mode = 0; } - DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X\n",flags,flags2)); - - open_file(fnum,cnum,fname,flags|flags2,mode); - if (!Files[fnum].open && flags==O_RDWR && errno!=ENOENT && fcbopen) { - flags = O_RDONLY; - *Access = 0; - open_mode = 0; - open_file(fnum,cnum,fname,flags,mode); - if (Files[fnum].open) - DEBUG(2,("Reduced to O_RDONLY on %s\n",fname)); + if (deny_mode > DENY_NONE && deny_mode!=DENY_FCB) { + DEBUG(2,("Invalid deny mode %d on file %s\n",deny_mode,fname)); + errno = EINVAL; + return; } if (deny_mode == DENY_FCB) deny_mode = DENY_DOS; - share_mode = (deny_mode<<4) | open_mode; - if (!Files[fnum].open) return; + if (lp_share_modes(SNUM(cnum))) { + int old_share=0; - if (action) { - if (file_existed && !(flags2 & O_TRUNC)) *action = 1; - if (!file_existed) *action = 2; - if (file_existed && (flags2 & O_TRUNC)) *action = 3; - } + if (file_existed) + old_share = get_share_mode(cnum,&sbuf,&share_pid); + if (share_pid) { + /* someone else has a share lock on it, check to see + if we can too */ + int old_open_mode = old_share&0xF; + int old_deny_mode = (old_share>>4)&7; + + if (deny_mode > 4 || old_deny_mode > 4 || old_open_mode > 2) { + DEBUG(2,("Invalid share mode (%d,%d,%d) on file %s\n", + deny_mode,old_deny_mode,old_open_mode,fname)); + errno = EACCES; + unix_ERR_class = ERRDOS; + unix_ERR_code = ERRbadshare; + return; + } - /* now check the share mode */ - if (!lp_share_modes(SNUM(cnum))) - return; + /* C. Hoch 11/21/95 Handle DOS (compatibility) mode on the same machine. + * Any number of read and/or write opens in compatibility mode from the + * same machine are allowed. + * Also, read opens in compatibility mode from different machines + * are allowed, even if the file is already opened for read in some + * share mode. This is "soft compatibility" mode (Microsoft Knowledge Base, + * WfWG, "How VSHARE386 Manages File Sharing", Q90239), and is handled in + * access_table(). + */ + if ((deny_mode==DENY_DOS || old_deny_mode==DENY_DOS) && + share_pid == getpid()) { + if (old_deny_mode != deny_mode) { + DEBUG(2,("Share violation on file %s\n",fname)); + errno = EACCES; + unix_ERR_class = ERRDOS; + unix_ERR_code = ERRbadshare; + return; + } + } else { + int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode); + + if ((access_allowed == AFAIL) || + (access_allowed == AREAD && flags == O_WRONLY) || + (access_allowed == AWRITE && flags == O_RDONLY)) { + DEBUG(2,("Share violation on file %s\n",fname)); + errno = EACCES; + unix_ERR_class = ERRDOS; + unix_ERR_code = ERRbadshare; + return; + } + + if (access_allowed == AREAD) + flags = O_RDONLY; + + if (access_allowed == AWRITE) + flags = O_WRONLY; + } + } + } - Files[fnum].share_mode = share_mode; + if (flags == O_RDONLY) { + /* when opening read only don't allow create and trunc bits */ + flags2 &= ~(O_TRUNC | O_CREAT); + } - old_share = get_share_mode(fnum,&share_pid); - Files[fnum].share_pending = True; + DEBUG(4,("calling open_file with flags=0x%X flags2=0x%X\n",flags,flags2)); - if (!share_pid) { - share_mode_pending = True; - return; + open_file(fnum,cnum,fname,flags|(flags2&~(O_TRUNC)),mode); + if (!Files[fnum].open && flags==O_RDWR && errno!=ENOENT && fcbopen) { + flags = O_RDONLY; + open_file(fnum,cnum,fname,flags,mode); } - if (old_share == DENY_DOS || deny_mode==DENY_DOS) - if (share_pid == getpid()) { - Files[fnum].share_pending = False; - return; + if (Files[fnum].open) { + int open_mode; + switch (flags) { + case O_RDONLY: + open_mode = 0; + break; + case O_RDWR: + open_mode = 2; + break; + case O_WRONLY: + open_mode = 1; + break; } - old_open_mode = old_share&0xF; - old_deny_mode = (old_share>>4)&7; + Files[fnum].share_mode = (deny_mode<<4) | open_mode; + Files[fnum].share_pending = True; - if (deny_mode > 4 || old_deny_mode > 4 || old_open_mode > 2) { - DEBUG(2,("Invalid share mode (%d,%d,%d) on file %s\n", - deny_mode,old_deny_mode,old_open_mode,fname)); - close_file(cnum); - errno = EACCES; - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadshare; - return; - } - - access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode); - - if ((access_allowed == AFAIL) || - (access_allowed == AREAD && open_mode == 1) || - (access_allowed == AWRITE && open_mode == 0)) { - close_file(fnum); - DEBUG(2,("Share violation on file %s\n",fname)); - errno = EACCES; - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadshare; - return; - } + if (Access) { + (*Access) = open_mode; + } + + if (action) { + if (file_existed && !(flags2 & O_TRUNC)) *action = 1; + if (!file_existed) *action = 2; + if (file_existed && (flags2 & O_TRUNC)) *action = 3; + } - if ((access_allowed == AALL) || - (access_allowed == AREAD && open_mode == 0) || - (access_allowed == AWRITE && open_mode == 1)) { - return; - } + if (!share_pid) + share_mode_pending = True; - if (access_allowed == AREAD && open_mode == 2) { - close_file(fnum); - open_mode = 0; - share_mode = (deny_mode<<4) | open_mode; - DEBUG(2,("Share retry on file %s\n",fname)); - open_file_shared(fnum,cnum,fname,share_mode,ofun,mode,Access,action); - return; + if (flags2&O_TRUNC) + truncate_unless_locked(fnum,cnum); } +} - if (access_allowed == AWRITE && open_mode == 2) { - close_file(fnum); - open_mode = 1; - share_mode = (deny_mode<<4) | open_mode; - DEBUG(2,("Share retry 2 on file %s\n",fname)); - open_file_shared(fnum,cnum,fname,share_mode,ofun,mode,Access,action); - return; - } - /* something weird has happened */ - DEBUG(2,("Share error 2 on file %s\n",fname)); - close_file(fnum); - errno = EACCES; - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadshare; -} /******************************************************************* check for files that we should now set our share modes on @@ -1389,13 +1401,16 @@ { int i; for (i=0;i<MAX_OPEN_FILES;i++) - if(Files[i].open && Files[i].share_pending && - lp_share_modes(SNUM(Files[i].cnum))) { - int pid=0; - get_share_mode(i,&pid); - if (!pid) { - set_share_mode(i,Files[i].share_mode); - Files[i].share_pending = False; + if(Files[i].open && Files[i].share_pending) { + if (lp_share_modes(SNUM(Files[i].cnum))) { + int pid=0; + get_share_mode_by_fnum(Files[i].cnum,i,&pid); + if (!pid) { + set_share_mode(i,Files[i].share_mode); + Files[i].share_pending = False; + } + } else { + Files[i].share_pending = False; } } } @@ -2228,6 +2243,8 @@ } } + reopen_logs(); + if (test && !lp_file_list_changed()) return(True); @@ -2241,7 +2258,6 @@ reopen_logs(); - { extern int Client; if (Client != -1) { @@ -2757,6 +2773,9 @@ if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); +#ifdef SMB_PASSWD + if (doencrypt) set_challenge(smb_buf(outbuf)); +#endif } CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ @@ -2801,6 +2820,9 @@ if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); +#ifdef SMB_PASSWD + if (doencrypt) set_challenge(smb_buf(outbuf)); +#endif } CVAL(outbuf,smb_flg) = 0x81; /* Reply, SMBlockread, SMBwritelock supported */ @@ -2843,6 +2865,9 @@ if (lp_security() == SEC_SERVER && server_cryptkey(outbuf)) { DEBUG(3,("using password server validation\n")); +#ifdef SMB_PASSWD + if (doencrypt) set_challenge(smb_buf(outbuf)); +#endif } if (lp_readraw() && lp_writeraw()) @@ -2898,11 +2923,10 @@ extern fstring remote_arch; int outsize = set_message(outbuf,1,0,True); int Index; - int choice=-1; + int choice= -1; int protocol; char *p; int bcc = SVAL(smb_buf(inbuf),-2); - int maybe_win95 = 0; int arch_known = 0; /* look through the protocol list to determine architecture */ @@ -2916,18 +2940,16 @@ strcpy(remote_arch,"Samba"); arch_known = 1; } else if (strcsequal(p,"NT LM 0.12")) { - if (maybe_win95) - strcpy(remote_arch,"Win95"); - else - strcpy(remote_arch,"WinNT"); + strcpy(remote_arch,"WinNT"); } else if (strcsequal(p,"Windows for Workgroups 3.1a")) { strcpy(remote_arch,"WfWg"); - maybe_win95 = 1; } Index++; } p += strlen(p) + 2; } + + DEBUG(4,("Got remote arch %s\n",remote_arch)); /* possibly reload - change of architecture */ reload_services(True); @@ -3174,7 +3196,7 @@ pstring fname; FILE *f; int snum = SNUM(cnum); - int i,foundi=-1; + int i,foundi= -1; int total_recs; if (max_connections <= 0) @@ -3324,6 +3346,10 @@ for (i=0;i<MAX_CONNECTIONS;i++) if (Connections[i].open) close_cnum(i,-1); +#ifdef DFS_AUTH + if (dcelogin_atmost_once) + dfs_unlogin(); +#endif if (!reason) { int oldlevel = DEBUGLEVEL; DEBUGLEVEL = 10; @@ -3513,7 +3539,7 @@ ****************************************************************************/ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize) { - static int pid=-1; + static int pid= -1; int outsize = 0; static int num_smb_messages = sizeof(smb_messages) / sizeof(struct smb_message_struct); @@ -3781,7 +3807,8 @@ #if PRIME_NMBD DEBUG(3,("priming nmbd\n")); { - struct in_addr ip = *interpret_addr2("localhost"); + struct in_addr ip; + ip = *interpret_addr2("localhost"); if (zero_ip(ip)) ip = *interpret_addr2("127.0.0.1"); *OutBuffer = 0; send_one_packet(OutBuffer,1,ip,137,SOCK_DGRAM); @@ -4006,11 +4033,9 @@ TimeInit(); - charset_initialise(); + setup_logging(argv[0],False); -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif + charset_initialise(); /* make absolutely sure we run as root - to handle cases whre people are crazy enough to have it setuid */ diff -u -r --new-file last-version/source/smb.h samba-1.9.15p5/source/smb.h --- last-version/source/smb.h Thu Nov 23 11:03:36 1995 +++ samba-1.9.15p5/source/smb.h Sun Dec 3 19:23:44 1995 @@ -116,6 +116,11 @@ #define DENY_NONE 4 #define DENY_FCB 7 +/* share types */ +#define STYPE_DISKTREE 0 /* Disk drive */ +#define STYPE_PRINTQ 1 /* Spooler queue */ +#define STYPE_DEVICE 2 /* Serial device */ +#define STYPE_IPC 3 /* Interprocess communication (IPC) */ /* SMB X/Open error codes for the ERRdos error class */ #define ERRbadfunc 1 /* Invalid function (or system call) */ @@ -491,7 +496,6 @@ #define SMBreadX 0x2E /* read and X */ #define SMBwriteX 0x2F /* write and X */ #define SMBsesssetupX 0x73 /* Session Set Up & X (including User Logon) */ -#define SMBtconX 0x75 /* tree connect and X */ #define SMBffirst 0x82 /* find first */ #define SMBfunique 0x83 /* find unique */ #define SMBfclose 0x84 /* find close */ @@ -615,7 +619,7 @@ char *readdirname(void *p); int dos_chmod(int cnum,char *fname,int mode); int smb_numwords(char *buf); -int get_share_mode(int fnum,int *pid); +int get_share_mode(int cnum,struct stat *sbuf,int *pid); void del_share_mode(int fnum); BOOL set_share_mode(int fnum,int mode); int DSTDiff(time_t t); @@ -713,6 +717,7 @@ char *uidtoname(int uid); char *gidtoname(int gid); int get_share_mode_byname(int cnum,char *fname,int *pid); +int get_share_mode_by_fnum(int cnum,int fnum,int *pid); BOOL check_file_sharing(int cnum,char *fname); char *StrCpy(char *dest,char *src); int unix_error_packet(char *inbuf,char *outbuf,int def_class,uint32 def_code,int line); @@ -773,6 +778,7 @@ char *smb_trans2_param(char *buf); char *smb_trans2_data(char *buf); BOOL strequal(char *,char *); +BOOL strnequal(char *,char *,int n); BOOL strcsequal(char *,char *); BOOL mask_match( char *str, char *regexp, int case_sig, BOOL trans2); int dos_mode(int ,char *,struct stat *); @@ -835,6 +841,11 @@ unsigned long interpret_addr(char *str); void mangle_name_83(char *s); BOOL lp_casesignames(void); +void setup_logging(char *pname,BOOL interactive); +#ifdef DFS_AUTH +void dfs_unlogin(void); +extern int dcelogin_atmost_once; +#endif #if AJT void ajt_panic(void); #endif diff -u -r --new-file last-version/source/smbpasswd.c samba-1.9.15p5/source/smbpasswd.c --- last-version/source/smbpasswd.c Thu Nov 23 11:03:37 1995 +++ samba-1.9.15p5/source/smbpasswd.c Sat Dec 2 19:31:49 1995 @@ -208,242 +208,239 @@ exit(1); } -int -main(int argc, char **argv) +int main(int argc, char **argv) { - int real_uid; - struct passwd *pwd; - fstring old_passwd; - uchar old_p16[16]; - uchar old_nt_p16[16]; - fstring new_passwd; - uchar new_p16[16]; - uchar new_nt_p16[16]; - char *p; - struct smb_passwd *smb_pwent; - FILE *fp; - BOOL valid_old_pwd = False; - BOOL got_valid_nt_entry = False; - long seekpos; - int pwfd; - char ascii_p16[66]; - char c; - int ret, i, err, writelen; - int lockfd = -1; - char *pfile = SMB_PASSWD_FILE; - char readbuf[16 * 1024]; - - charset_initialise(); - -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif - + int real_uid; + struct passwd *pwd; + fstring old_passwd; + uchar old_p16[16]; + uchar old_nt_p16[16]; + fstring new_passwd; + uchar new_p16[16]; + uchar new_nt_p16[16]; + char *p; + struct smb_passwd *smb_pwent; + FILE *fp; + BOOL valid_old_pwd = False; + BOOL got_valid_nt_entry = False; + long seekpos; + int pwfd; + char ascii_p16[66]; + char c; + int ret, i, err, writelen; + int lockfd = -1; + char *pfile = SMB_PASSWD_FILE; + char readbuf[16 * 1024]; + + setup_logging(argv[0],True); + + charset_initialise(); + #ifndef DEBUG_PASSWORD - /* Check the effective uid */ - if (geteuid() != 0) { - fprintf(stderr, "%s: Must be setuid root.\n", argv[0]); - exit(1); - } + /* Check the effective uid */ + if (geteuid() != 0) { + fprintf(stderr, "%s: Must be setuid root.\n", argv[0]); + exit(1); + } #endif - - /* Get the real uid */ - real_uid = getuid(); - - /* Deal with usage problems */ - if (real_uid == 0) { - /* As root we can change anothers password. */ - if (argc != 1 && argc != 2) - usage(argv[0]); - } else if (argc != 1) - usage(argv[0]); - - - if (real_uid == 0 && argc == 2) { - /* If we are root we can change anothers password. */ - strncpy(user_name, argv[1], sizeof(user_name) - 1); - user_name[sizeof(user_name) - 1] = '\0'; - pwd = getpwnam(user_name); - } else { - pwd = getpwuid(real_uid); - } - - if (pwd == 0) { - fprintf(stderr, "%s: Unable to get UNIX password entry for user.\n", argv[0]); - exit(1); - } - /* If we are root we don't ask for the old password. */ - old_passwd[0] = '\0'; - if (real_uid != 0) { - p = getpass("Old SMB password:"); - strncpy(old_passwd, p, sizeof(fstring)); - old_passwd[sizeof(fstring)-1] = '\0'; - } - new_passwd[0] = '\0'; - p = getpass("New SMB password:"); - strncpy(new_passwd, p, sizeof(fstring)); - new_passwd[sizeof(fstring)-1] = '\0'; - p = getpass("Retype new SMB password:"); - if (strcmp(p, new_passwd)) { - fprintf(stderr, "%s: Mismatch - password unchanged.\n", argv[0]); - exit(1); - } - - if (new_passwd[0] == '\0') { - printf("Password not set\n"); - exit(0); - } - - /* Calculate the MD4 hash (NT compatible) of the old and new passwords */ - memset(old_nt_p16, '\0', 16); - E_md4hash((uchar *)old_passwd, old_nt_p16); - - memset(new_nt_p16, '\0', 16); - E_md4hash((uchar *) new_passwd, new_nt_p16); - - /* Mangle the passwords into Lanman format */ - old_passwd[14] = '\0'; - strupper(old_passwd); - new_passwd[14] = '\0'; - strupper(new_passwd); - - /* - * Calculate the SMB (lanman) hash functions of both old and new passwords. - */ - - memset(old_p16, '\0', 16); - E_P16((uchar *) old_passwd, old_p16); - - memset(new_p16, '\0', 16); - E_P16((uchar *) new_passwd, new_p16); - - /* - * Open the smbpaswd file XXXX - we need to parse smb.conf to get the - * filename - */ - if ((fp = fopen(pfile, "r+")) == NULL) { - err = errno; - fprintf(stderr, "%s: Failed to open password file %s.\n", - argv[0], pfile); - errno = err; - perror(argv[0]); - exit(err); - } - /* Set read buffer to 16k for effiecient reads */ - setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf)); - - /* make sure it is only rw by the owner */ - chmod(pfile, 0600); - - /* Lock the smbpasswd file for write. */ - if ((lockfd = pw_file_lock(pfile, F_WRLCK, 5)) < 0) { - err = errno; - fprintf(stderr, "%s: Failed to lock password file %s.\n", - argv[0], pfile); - fclose(fp); - errno = err; - perror(argv[0]); - exit(err); - } - /* Get the smb passwd entry for this user */ - smb_pwent = _my_get_smbpwnam(fp, pwd->pw_name, &valid_old_pwd, - &got_valid_nt_entry, &seekpos); - if (smb_pwent == NULL) { - fprintf(stderr, "%s: Failed to find entry for user %s in file %s.\n", - argv[0], pwd->pw_name, pfile); - fclose(fp); - pw_file_unlock(lockfd); - exit(1); - } - /* If we are root we don't need to check the old password. */ - if (real_uid != 0) { - if ((valid_old_pwd == False) || (smb_pwent->smb_passwd == NULL)) { - fprintf(stderr, "%s: User %s is disabled, plase contact your administrator to enable it.\n", argv[0], pwd->pw_name); - fclose(fp); - pw_file_unlock(lockfd); - exit(1); - } - /* Check the old Lanman password */ - if (memcmp(old_p16, smb_pwent->smb_passwd, 16)) { - fprintf(stderr, "%s: Couldn't change password.\n", argv[0]); - fclose(fp); - pw_file_unlock(lockfd); - exit(1); - } - /* Check the NT password if it exists */ - if (smb_pwent->smb_nt_passwd != NULL) { - if (memcmp(old_nt_p16, smb_pwent->smb_nt_passwd, 16)) { - fprintf(stderr, "%s: Couldn't change password.\n", argv[0]); - fclose(fp); - pw_file_unlock(lockfd); - exit(1); - } - } - } - /* - * If we get here either we were root or the old password checked out - * ok. - */ - /* Create the 32 byte representation of the new p16 */ - for (i = 0; i < 16; i++) { - sprintf(&ascii_p16[i * 2], "%02X", (uchar) new_p16[i]); - } - if(got_valid_nt_entry) { - /* Add on the NT md4 hash */ - ascii_p16[32] = ':'; - for (i = 0; i < 16; i++) { - sprintf(&ascii_p16[(i * 2)+33], "%02X", (uchar) new_nt_p16[i]); - } + + /* Get the real uid */ + real_uid = getuid(); + + /* Deal with usage problems */ + if (real_uid == 0) { + /* As root we can change anothers password. */ + if (argc != 1 && argc != 2) + usage(argv[0]); + } else if (argc != 1) + usage(argv[0]); + + + if (real_uid == 0 && argc == 2) { + /* If we are root we can change anothers password. */ + strncpy(user_name, argv[1], sizeof(user_name) - 1); + user_name[sizeof(user_name) - 1] = '\0'; + pwd = getpwnam(user_name); + } else { + pwd = getpwuid(real_uid); + } + + if (pwd == 0) { + fprintf(stderr, "%s: Unable to get UNIX password entry for user.\n", argv[0]); + exit(1); + } + /* If we are root we don't ask for the old password. */ + old_passwd[0] = '\0'; + if (real_uid != 0) { + p = getpass("Old SMB password:"); + strncpy(old_passwd, p, sizeof(fstring)); + old_passwd[sizeof(fstring)-1] = '\0'; + } + new_passwd[0] = '\0'; + p = getpass("New SMB password:"); + strncpy(new_passwd, p, sizeof(fstring)); + new_passwd[sizeof(fstring)-1] = '\0'; + p = getpass("Retype new SMB password:"); + if (strcmp(p, new_passwd)) { + fprintf(stderr, "%s: Mismatch - password unchanged.\n", argv[0]); + exit(1); + } + + if (new_passwd[0] == '\0') { + printf("Password not set\n"); + exit(0); + } + + /* Calculate the MD4 hash (NT compatible) of the old and new passwords */ + memset(old_nt_p16, '\0', 16); + E_md4hash((uchar *)old_passwd, old_nt_p16); + + memset(new_nt_p16, '\0', 16); + E_md4hash((uchar *) new_passwd, new_nt_p16); + + /* Mangle the passwords into Lanman format */ + old_passwd[14] = '\0'; + strupper(old_passwd); + new_passwd[14] = '\0'; + strupper(new_passwd); + + /* + * Calculate the SMB (lanman) hash functions of both old and new passwords. + */ + + memset(old_p16, '\0', 16); + E_P16((uchar *) old_passwd, old_p16); + + memset(new_p16, '\0', 16); + E_P16((uchar *) new_passwd, new_p16); + + /* + * Open the smbpaswd file XXXX - we need to parse smb.conf to get the + * filename + */ + if ((fp = fopen(pfile, "r+")) == NULL) { + err = errno; + fprintf(stderr, "%s: Failed to open password file %s.\n", + argv[0], pfile); + errno = err; + perror(argv[0]); + exit(err); + } + /* Set read buffer to 16k for effiecient reads */ + setvbuf(fp, readbuf, _IOFBF, sizeof(readbuf)); + + /* make sure it is only rw by the owner */ + chmod(pfile, 0600); + + /* Lock the smbpasswd file for write. */ + if ((lockfd = pw_file_lock(pfile, F_WRLCK, 5)) < 0) { + err = errno; + fprintf(stderr, "%s: Failed to lock password file %s.\n", + argv[0], pfile); + fclose(fp); + errno = err; + perror(argv[0]); + exit(err); + } + /* Get the smb passwd entry for this user */ + smb_pwent = _my_get_smbpwnam(fp, pwd->pw_name, &valid_old_pwd, + &got_valid_nt_entry, &seekpos); + if (smb_pwent == NULL) { + fprintf(stderr, "%s: Failed to find entry for user %s in file %s.\n", + argv[0], pwd->pw_name, pfile); + fclose(fp); + pw_file_unlock(lockfd); + exit(1); + } + /* If we are root we don't need to check the old password. */ + if (real_uid != 0) { + if ((valid_old_pwd == False) || (smb_pwent->smb_passwd == NULL)) { + fprintf(stderr, "%s: User %s is disabled, plase contact your administrator to enable it.\n", argv[0], pwd->pw_name); + fclose(fp); + pw_file_unlock(lockfd); + exit(1); } - /* - * Do an atomic write into the file at the position defined by - * seekpos. - */ - pwfd = fileno(fp); - ret = lseek(pwfd, seekpos - 1, SEEK_SET); - if (ret != seekpos - 1) { - err = errno; - fprintf(stderr, "%s: seek fail on file %s.\n", - argv[0], pfile); - fclose(fp); - errno = err; - perror(argv[0]); - pw_file_unlock(lockfd); - exit(1); - } - /* Sanity check - ensure the character is a ':' */ - if (read(pwfd, &c, 1) != 1) { - err = errno; - fprintf(stderr, "%s: read fail on file %s.\n", - argv[0], pfile); - fclose(fp); - errno = err; - perror(argv[0]); - pw_file_unlock(lockfd); - exit(1); - } - if (c != ':') { - fprintf(stderr, "%s: sanity check on passwd file %s failed.\n", - argv[0], pfile); - fclose(fp); - pw_file_unlock(lockfd); - exit(1); - } - writelen = (got_valid_nt_entry) ? 65 : 32; - if (write(pwfd, ascii_p16, writelen) != writelen) { - err = errno; - fprintf(stderr, "%s: write fail in file %s.\n", - argv[0], pfile); - fclose(fp); - errno = err; - perror(argv[0]); - pw_file_unlock(lockfd); - exit(err); - } + /* Check the old Lanman password */ + if (memcmp(old_p16, smb_pwent->smb_passwd, 16)) { + fprintf(stderr, "%s: Couldn't change password.\n", argv[0]); + fclose(fp); + pw_file_unlock(lockfd); + exit(1); + } + /* Check the NT password if it exists */ + if (smb_pwent->smb_nt_passwd != NULL) { + if (memcmp(old_nt_p16, smb_pwent->smb_nt_passwd, 16)) { + fprintf(stderr, "%s: Couldn't change password.\n", argv[0]); fclose(fp); pw_file_unlock(lockfd); - printf("Password changed\n"); - return 0; + exit(1); + } + } + } + /* + * If we get here either we were root or the old password checked out + * ok. + */ + /* Create the 32 byte representation of the new p16 */ + for (i = 0; i < 16; i++) { + sprintf(&ascii_p16[i * 2], "%02X", (uchar) new_p16[i]); + } + if(got_valid_nt_entry) { + /* Add on the NT md4 hash */ + ascii_p16[32] = ':'; + for (i = 0; i < 16; i++) { + sprintf(&ascii_p16[(i * 2)+33], "%02X", (uchar) new_nt_p16[i]); + } + } + /* + * Do an atomic write into the file at the position defined by + * seekpos. + */ + pwfd = fileno(fp); + ret = lseek(pwfd, seekpos - 1, SEEK_SET); + if (ret != seekpos - 1) { + err = errno; + fprintf(stderr, "%s: seek fail on file %s.\n", + argv[0], pfile); + fclose(fp); + errno = err; + perror(argv[0]); + pw_file_unlock(lockfd); + exit(1); + } + /* Sanity check - ensure the character is a ':' */ + if (read(pwfd, &c, 1) != 1) { + err = errno; + fprintf(stderr, "%s: read fail on file %s.\n", + argv[0], pfile); + fclose(fp); + errno = err; + perror(argv[0]); + pw_file_unlock(lockfd); + exit(1); + } + if (c != ':') { + fprintf(stderr, "%s: sanity check on passwd file %s failed.\n", + argv[0], pfile); + fclose(fp); + pw_file_unlock(lockfd); + exit(1); + } + writelen = (got_valid_nt_entry) ? 65 : 32; + if (write(pwfd, ascii_p16, writelen) != writelen) { + err = errno; + fprintf(stderr, "%s: write fail in file %s.\n", + argv[0], pfile); + fclose(fp); + errno = err; + perror(argv[0]); + pw_file_unlock(lockfd); + exit(err); + } + fclose(fp); + pw_file_unlock(lockfd); + printf("Password changed\n"); + return 0; } #else @@ -453,7 +450,7 @@ int main(int argc, char **argv) { - printf("smb password encryption not selected in Makefile\n"); - return 0; + printf("smb password encryption not selected in Makefile\n"); + return 0; } #endif diff -u -r --new-file last-version/source/status.c samba-1.9.15p5/source/status.c --- last-version/source/status.c Thu Nov 23 11:14:41 1995 +++ samba-1.9.15p5/source/status.c Sat Dec 2 19:32:46 1995 @@ -57,6 +57,8 @@ BOOL processes_only=False; int last_pid=0; + setup_logging(argv[0],True); + charset_initialise(); DEBUGLEVEL = 0; diff -u -r --new-file last-version/source/testparm.c samba-1.9.15p5/source/testparm.c --- last-version/source/testparm.c Thu Nov 23 11:03:37 1995 +++ samba-1.9.15p5/source/testparm.c Sat Dec 2 19:33:58 1995 @@ -46,11 +46,9 @@ pstring configfile; int s; + setup_logging(argv[0],True); + charset_initialise(); - -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif if (argc < 2) strcpy(configfile,CONFIGFILE); diff -u -r --new-file last-version/source/testprns.c samba-1.9.15p5/source/testprns.c --- last-version/source/testprns.c Thu Nov 23 11:03:37 1995 +++ samba-1.9.15p5/source/testprns.c Sat Dec 2 19:32:09 1995 @@ -43,11 +43,9 @@ { char *pszTemp; - charset_initialise(); + setup_logging(argv[0],True); -#ifdef SYSLOG - openlog(argv[0], LOG_PID, LOG_DAEMON); -#endif + charset_initialise(); if (argc < 2 || argc > 3) printf("Usage: testprns printername [printcapfile]\n"); diff -u -r --new-file last-version/source/trans2.c samba-1.9.15p5/source/trans2.c --- last-version/source/trans2.c Fri Nov 24 14:46:43 1995 +++ samba-1.9.15p5/source/trans2.c Sun Dec 3 19:26:38 1995 @@ -608,6 +608,10 @@ /* a special case for 16 bit apps */ if (strequal(mask,"????????.???")) strcpy(mask,"*"); + /* handle broken clients that send us old 8.3 format */ + string_sub(mask,"????????","*"); + string_sub(mask,".???",".*"); + /* Save the wildcard match and attribs we are using on this directory - needed as lanman2 assumes these are being saved between calls */ @@ -1445,7 +1449,7 @@ { int cnum; int outsize = 0; - int dptr_num=-1; + int dptr_num= -1; cnum = SVAL(inbuf,smb_tid); dptr_num = SVAL(inbuf,smb_vwv0); diff -u -r --new-file last-version/source/util.c samba-1.9.15p5/source/util.c --- last-version/source/util.c Thu Nov 23 11:19:04 1995 +++ samba-1.9.15p5/source/util.c Sat Dec 2 19:36:08 1995 @@ -90,9 +90,29 @@ static char *filename_dos(char *path,char *buf); +static BOOL stdout_logging = False; + +/******************************************************************* + get ready for syslog stuff + ******************************************************************/ +void setup_logging(char *pname,BOOL interactive) +{ +#ifdef SYSLOG + if (!interactive) { + char *p = strrchr(pname,'/'); + if (p) pname = p+1; + openlog(pname, LOG_PID, LOG_DAEMON); + } +#endif + if (interactive) { + stdout_logging = True; + dbf = stdout; + } +} + /******************************************************************* -write an debug message on the debugfile. This is called bug the DEBUG +write an debug message on the debugfile. This is called by the DEBUG macro ********************************************************************/ #ifdef __STDC__ @@ -104,7 +124,20 @@ { char *format_str; #endif - va_list ap; + va_list ap; + +#ifdef __STDC__ + va_start(ap, format_str); +#else + va_start(ap); + format_str = va_arg(ap,char *); +#endif + + if (stdout_logging) { + vfprintf(dbf,format_str,ap); + va_end(ap); + return(0); + } #ifdef SYSLOG if (!lp_syslog_only()) @@ -119,13 +152,6 @@ return(0); } } - -#ifdef __STDC__ - va_start(ap, format_str); -#else - va_start(ap); - format_str = va_arg(ap,char *); -#endif #ifdef SYSLOG if (syslog_level < lp_syslog()) @@ -155,13 +181,15 @@ msgbuf[255] = '\0'; syslog(priority, "%s", msgbuf); } +#endif +#ifdef SYSLOG if (!lp_syslog_only()) #endif - { - vfprintf(dbf,format_str,ap); - fflush(dbf); - } + { + vfprintf(dbf,format_str,ap); + fflush(dbf); + } va_end(ap); return(0); @@ -1102,6 +1130,16 @@ if (!s1 || !s2) return(False); return(StrCaseCmp(s1,s2)==0); +} + +/******************************************************************* + compare 2 strings up to and including the nth char. + ******************************************************************/ +BOOL strnequal(char *s1,char *s2,int n) +{ + if (!s1 || !s2 || !n) return(False); + + return(StrnCaseCmp(s1,s2,n)==0); } /******************************************************************* diff -u -r --new-file last-version/source/version.h samba-1.9.15p5/source/version.h --- last-version/source/version.h Fri Nov 24 23:20:42 1995 +++ samba-1.9.15p5/source/version.h Sun Dec 3 22:13:02 1995 @@ -1 +1 @@ -#define VERSION "1.9.15p4" +#define VERSION "1.9.15p5"